Convert Figma .fig files to clean, optimized JSON for AI-powered design implementation.
fig2json extracts and transforms Figma design files into structured JSON, making it easy for LLMs to understand and implement your designs. The tool removes Figma-specific metadata and applies intelligent transformations to produce JSON optimized for HTML/CSS conversion.
In Figma, go to the top-left menu:
- Click File → Save local copy...
- Save the
.figfile to your computer
Run fig2json on your saved file:
fig2json your-design.fig output-directoryThis will:
- Extract all contents to
output-directory/ - Convert the design to
output-directory/canvas.json
Ask your LLM to implement the design:
Implement the design found in output-directory/canvas.json
The clean JSON structure makes it easier for AI to understand your design and hopefully generate accurate HTML/CSS.
Tip: For easier LLM consumption, consider using jq to extract specific parts of the design or to further process the JSON before sending it to your LLM.
cargo install fig2jsonOr build from source:
cargo build --release
# Binary will be at target/release/fig2jsonConvert a .fig file and extract to a directory:
fig2json design.fig output-dirConvert a .fig file to stdout:
fig2json design.figConvert to a specific output file:
fig2json design.fig -o output.json| Flag | Description |
|---|---|
-o, --output <FILE> |
Output JSON file path (default: stdout). Cannot be used with extract directory mode. |
--compact |
Output compact JSON instead of pretty-printed (default is indented). |
-v, --verbose |
Enable verbose output for debugging. |
--raw |
Generate both transformed .json and raw .raw.json files. The raw version contains the original data without transformations. |
Extract and convert with verbose output:
fig2json design.fig output-dir --verboseCompact JSON output:
fig2json design.fig -o compact.json --compactGenerate both transformed and raw JSON:
fig2json design.fig output-dir --raw
# Creates: output-dir/canvas.json and output-dir/canvas.raw.jsonPipe to other tools:
fig2json design.fig | jq '.document.children[0]'The tool applies intelligent transformations to clean up the JSON:
- Removes default values:
blendMode: "NORMAL", default letter spacing, line height - Removes Figma-specific metadata: Internal IDs, text data, image thumbnails
- Removes redundant fields: Derived layout sizes, empty font properties
- Filters internal nodes: Removes
internalOnlyelements - Preserves geometry: Keeps SVG paths for icons and images
- Optimizes structure: Only essential fields for HTML/CSS rendering
Use the --raw flag to also generate the untransformed JSON for comparison.
After extraction, you'll find:
output-directory/
├── canvas.json # Main design file (transformed)
├── canvas.raw.json # Raw untransformed data (if --raw flag used)
└── [other extracted files]
The canvas.json file contains the complete design tree with all layers, styles, and properties needed for implementation.
This project was inspired by Evan Wallace's Figma File Parser.
This project was mostly vibe-coded with Claude Code.
- Transformed JSON (default): Clean, optimized structure with Figma metadata removed and defaults stripped. Best for AI consumption and HTML/CSS generation.
- Raw JSON (
--rawflag): Original decoded data with all Figma-specific fields intact. Useful for debugging or advanced use cases.
No, this tool works with locally saved .fig files. You need to use Figma's "Save local copy" feature to export the file first.
MIT