obsidian/wiki/concepts/figma-fig-binary-format.md
2026-05-10 21:33:54 +01:00

58 lines
2.4 KiB
Markdown

---
title: "Figma .fig File — Proprietary Binary Format; Assets Extractable, Layout Data Not"
aliases: [figma-fig-format, fig-binary, figma-file-format]
tags: [figma, binary, file-format, mcp, design]
sources:
- "daily/2026-05-10.md"
created: 2026-05-10
updated: 2026-05-10
---
# Figma .fig File — Proprietary Binary Format
## Key Takeaways
- `.fig` file = ZIP archive containing `canvas.fig` (binary, magic bytes `fig-kiwij`, proprietary compressed format)
- Image assets (photos, icons) stored as regular files inside the ZIP — accessible via `unzip`
- Layer positions, offsets, component definitions, and text content NOT accessible without Figma
- `strings` command on `canvas.fig` returns nothing useful — the binary is compressed/encoded
- Figma plugins cannot be installed from terminal — only through Figma Desktop or Browser UI
## Details
A `.fig` file can be unzipped:
```bash
unzip design.fig -d design_extracted/
# → canvas.fig (the binary, ~95% of file size)
# → images/ (PNG/JPEG assets referenced in the design)
# → thumbnails/ (preview images)
```
The `canvas.fig` file has magic bytes `fig-kiwij` and is a proprietary compressed binary. It is NOT parseable without the Figma proprietary decoder — `strings`, `jq`, `binwalk`, and similar tools yield nothing useful.
## What You Can and Cannot Do
| Goal | Approach | Works? |
|------|----------|--------|
| Extract image assets from .fig | `unzip file.fig -d out/` | ✅ Yes |
| Read layer names / positions | `unzip` + parse `canvas.fig` | ❌ No |
| Read component structure | `unzip` + parse `canvas.fig` | ❌ No |
| Read text content | `unzip` + parse `canvas.fig` | ❌ No |
| Full design data | Figma REST API (`GET /v1/files/:key`) | ✅ Yes (requires key) |
| Full design data from local file | Figma Desktop (File → Export) | ✅ Yes |
## Figma REST API Alternative
To get layer/component/text data programmatically:
```bash
curl -H "X-Figma-Token: $FIGMA_TOKEN" \
"https://api.figma.com/v1/files/$FILE_KEY" | jq '.document'
```
The `FILE_KEY` is the hash from the Figma URL: `figma.com/design/{FILE_KEY}/...`
## Context
Discovered while attempting to parse a `.fig` file locally to extract component information for a project setup. The Figma MCP server (`plugin:figma`) uses the Figma REST API under the hood — it requires the file to be in Figma's cloud, not a local `.fig` file.