Excalidraw Export
Generate Excalidraw diagrams from natural language and export them as PNG/SVG images, end-to-end.
Language
Match user's language: Respond in the same language the user uses.
End-to-End Workflow
Progress:
Prerequisites
On first use, run the setup script to check dependencies:
bash <SKILL_DIR>/scripts/setup.sh
Required:
- Python 3.8+
resvg (brew install resvg) — fast SVG-to-PNG rasterizer
fonttools + brotli (pip install fonttools brotli) — extracts embedded hand-drawn fonts from SVG and converts <text> to <path>, preserving Excalifont + Xiaolai without a browser
- Internet access (uses kroki.io for rendering)
Optional fallback:
- Google Chrome — used as fallback if resvg/fonttools unavailable
If only SVG output is needed, no extra tools are required.
Run preflight to verify all dependencies programmatically:
python3 <SKILL_DIR>/scripts/export.py --preflight
Step 1: Understand the Request
Determine:
- Diagram type: flowchart, relationship, mind map, architecture, sequence, ER, class, swimlane, data flow
- Key elements: entities, steps, concepts
- Relationships: flow direction, connections, hierarchy
Step 2: Generate .excalidraw JSON
Create a valid .excalidraw file following the schema. Read the reference docs for details:
- Read
<SKILL_DIR>/references/excalidraw-schema.md for the JSON schema
- Read
<SKILL_DIR>/references/element-types.md for element specifications
Critical rules:
- All text elements MUST use
fontFamily: 5 (Excalifont) for the hand-drawn style. This is excalidraw's current default font. kroki.io will auto-embed Excalifont (hand-drawn Latin) + Xiaolai (hand-drawn CJK) as woff2. The export script extracts these glyphs and converts <text> to <path>, so resvg renders the hand-drawn fonts perfectly without a browser.
fontFamily: 1 (Virgil) is deprecated — kroki will NOT embed Xiaolai for it, causing CJK to fall back to system fonts
- Only use
fontFamily: 3 (Cascadia) for code identifiers / monospace text
- All IDs must be unique
- Keep element count under 20 for clarity
- Use consistent spacing: 200-300px horizontal, 100-150px vertical
Color palette:
| Role |
Color |
| Primary entities |
#a5d8ff (light blue) |
| Process steps |
#b2f2bb (light green) |
| Important/central |
#ffd43b (yellow) |
| Warnings/errors |
#ffc9c9 (light red) |
| Default stroke |
#1e1e1e |
File structure:
{
"type": "excalidraw",
"version": 2,
"source": "https://excalidraw.com",
"elements": [],
"appState": {
"viewBackgroundColor": "#ffffff",
"gridSize": 20
},
"files": {}
}
Save the file as <descriptive-name>.excalidraw.
Step 3: Export to PNG/SVG
Run the export script to convert the .excalidraw file to an image:
# Export to PNG (default, 2x resolution for retina)
python3 <SKILL_DIR>/scripts/export.py <file>.excalidraw
# Export to SVG
python3 <SKILL_DIR>/scripts/export.py <file>.excalidraw -f svg
# Export both PNG and SVG
python3 <SKILL_DIR>/scripts/export.py <file>.excalidraw -f png -f svg
# Custom output path
python3 <SKILL_DIR>/scripts/export.py <file>.excalidraw -o output.png
# Higher resolution (3x)
python3 <SKILL_DIR>/scripts/export.py <file>.excalidraw --scale 3
# Dark theme
python3 <SKILL_DIR>/scripts/export.py <file>.excalidraw --dark
Step 4: Deliver Result
Always provide:
- The exported image file (PNG or SVG)
- The source
.excalidraw file (for future editing)
- Brief summary of what was created
Example delivery:
Created: system-architecture.png (86 KB)
Source: system-architecture.excalidraw
Type: Architecture diagram
Elements: 8 rectangles, 7 arrows, 1 title
The .excalidraw file can be edited at https://excalidraw.com or with the VS Code Excalidraw extension.
Diagram Type Guide
| User Intent |
Type |
Keywords |
| Sequential process |
Flowchart |
"workflow", "process", "steps" |
| Entity connections |
Relationship |
"relationship", "dependencies" |
| Concept hierarchy |
Mind Map |
"mind map", "concepts", "ideas" |
| System components |
Architecture |
"architecture", "system", "modules" |
| Data movement |
Data Flow (DFD) |
"data flow", "data processing" |
| Cross-functional |
Swimlane |
"business process", "actors" |
| OOP design |
Class Diagram |
"class", "inheritance", "OOP" |
| Message flow |
Sequence |
"sequence", "interaction", "timeline" |
| Database design |
ER Diagram |
"database", "entity", "data model" |
Error Handling
| Issue |
Solution |
| kroki.io unreachable |
Check internet; output .excalidraw only, inform user to export manually |
| fonttools/brotli not installed |
Run pip install fonttools brotli; falls back to Chrome or system fonts |
| CJK text shows as boxes |
Use fontFamily: 5 so kroki embeds Xiaolai; ensure fonttools+brotli installed for text-to-path |
| Elements overlap |
Increase spacing; use 200-300px horizontal gap |
| Too many elements |
Break into multiple diagrams; suggest high-level + detail views |
PNG Backend Priority
| Backend |
Hand-drawn English |
Hand-drawn CJK |
Notes |
| text-to-path + resvg |
✅ Excalifont |
✅ Xiaolai |
Recommended. Extracts woff2 glyphs via fonttools, converts <text> → <path>. Fast, no browser. |
| Chrome headless |
✅ Excalifont |
✅ Xiaolai |
Fallback. Renders @font-face natively but heavy (~500MB). |
| resvg (no fonttools) |
❌ System font |
❌ System font |
Last resort. Ignores @font-face, uses system fonts. |
Limitations
- Requires internet access (kroki.io for SVG rendering)
- Maximum recommended: 20 elements per diagram
- No embedded image support in auto-generation
- Hand-drawn roughness uses default settings
1---2name: excalidraw-export3description: Generate Excalidraw diagrams and export to PNG/SVG images. Use when asked to 'create a diagram', 'draw a flowchart', 'visualize architecture', 'make a mind map', 'generate excalidraw', 'export diagram to png', 'diagram to image'. Supports flowcharts, relationship diagrams, mind maps, architecture diagrams, sequence diagrams, ER diagrams, and more. End-to-end: natural language -> .excalidraw JSON -> PNG/SVG image. Trigger: 'excalidraw', 'diagram', 'flowchart', 'visualize', 'architecture diagram', '画图', '流程图', '架构图', '思维导图', '导出图片'.4---56# Excalidraw Export78Generate Excalidraw diagrams from natural language and export them as PNG/SVG images, end-to-end.910## Language1112**Match user's language**: Respond in the same language the user uses.1314## End-to-End Workflow1516Progress:17- [ ] Step 1: Understand the request18- [ ] Step 2: Generate .excalidraw JSON19- [ ] Step 3: Export to PNG/SVG20- [ ] Step 4: Deliver result2122## Prerequisites2324On first use, run the setup script to check dependencies:2526```bash27bash <SKILL_DIR>/scripts/setup.sh28```2930Required:31- Python 3.8+32- `resvg` (`brew install resvg`) — fast SVG-to-PNG rasterizer33- `fonttools` + `brotli` (`pip install fonttools brotli`) — extracts embedded hand-drawn fonts from SVG and converts `<text>` to `<path>`, preserving Excalifont + Xiaolai without a browser34- Internet access (uses kroki.io for rendering)3536Optional fallback:37- Google Chrome — used as fallback if resvg/fonttools unavailable3839If only SVG output is needed, no extra tools are required.4041Run preflight to verify all dependencies programmatically:4243```bash44python3 <SKILL_DIR>/scripts/export.py --preflight45```4647### Step 1: Understand the Request4849Determine:501. **Diagram type**: flowchart, relationship, mind map, architecture, sequence, ER, class, swimlane, data flow512. **Key elements**: entities, steps, concepts523. **Relationships**: flow direction, connections, hierarchy5354### Step 2: Generate .excalidraw JSON5556Create a valid `.excalidraw` file following the schema. Read the reference docs for details:5758- Read `<SKILL_DIR>/references/excalidraw-schema.md` for the JSON schema59- Read `<SKILL_DIR>/references/element-types.md` for element specifications6061**Critical rules:**62- All text elements MUST use `fontFamily: 5` (Excalifont) for the hand-drawn style. This is excalidraw's current default font. kroki.io will auto-embed Excalifont (hand-drawn Latin) + Xiaolai (hand-drawn CJK) as woff2. The export script extracts these glyphs and converts `<text>` to `<path>`, so resvg renders the hand-drawn fonts perfectly without a browser.63- `fontFamily: 1` (Virgil) is **deprecated** — kroki will NOT embed Xiaolai for it, causing CJK to fall back to system fonts64- Only use `fontFamily: 3` (Cascadia) for code identifiers / monospace text65- All IDs must be unique66- Keep element count under 20 for clarity67- Use consistent spacing: 200-300px horizontal, 100-150px vertical6869**Color palette:**70| Role | Color |71|------|-------|72| Primary entities | `#a5d8ff` (light blue) |73| Process steps | `#b2f2bb` (light green) |74| Important/central | `#ffd43b` (yellow) |75| Warnings/errors | `#ffc9c9` (light red) |76| Default stroke | `#1e1e1e` |7778**File structure:**79```json80{81 "type": "excalidraw",82 "version": 2,83 "source": "https://excalidraw.com",84 "elements": [],85 "appState": {86 "viewBackgroundColor": "#ffffff",87 "gridSize": 2088 },89 "files": {}90}91```9293Save the file as `<descriptive-name>.excalidraw`.9495### Step 3: Export to PNG/SVG9697Run the export script to convert the .excalidraw file to an image:9899```bash100# Export to PNG (default, 2x resolution for retina)101python3 <SKILL_DIR>/scripts/export.py <file>.excalidraw102103# Export to SVG104python3 <SKILL_DIR>/scripts/export.py <file>.excalidraw -f svg105106# Export both PNG and SVG107python3 <SKILL_DIR>/scripts/export.py <file>.excalidraw -f png -f svg108109# Custom output path110python3 <SKILL_DIR>/scripts/export.py <file>.excalidraw -o output.png111112# Higher resolution (3x)113python3 <SKILL_DIR>/scripts/export.py <file>.excalidraw --scale 3114115# Dark theme116python3 <SKILL_DIR>/scripts/export.py <file>.excalidraw --dark117```118119### Step 4: Deliver Result120121Always provide:1221. The exported image file (PNG or SVG)1232. The source `.excalidraw` file (for future editing)1243. Brief summary of what was created125126**Example delivery:**127```128Created: system-architecture.png (86 KB)129Source: system-architecture.excalidraw130Type: Architecture diagram131Elements: 8 rectangles, 7 arrows, 1 title132133The .excalidraw file can be edited at https://excalidraw.com or with the VS Code Excalidraw extension.134```135136## Diagram Type Guide137138| User Intent | Type | Keywords |139|-------------|------|----------|140| Sequential process | Flowchart | "workflow", "process", "steps" |141| Entity connections | Relationship | "relationship", "dependencies" |142| Concept hierarchy | Mind Map | "mind map", "concepts", "ideas" |143| System components | Architecture | "architecture", "system", "modules" |144| Data movement | Data Flow (DFD) | "data flow", "data processing" |145| Cross-functional | Swimlane | "business process", "actors" |146| OOP design | Class Diagram | "class", "inheritance", "OOP" |147| Message flow | Sequence | "sequence", "interaction", "timeline" |148| Database design | ER Diagram | "database", "entity", "data model" |149150## Error Handling151152| Issue | Solution |153|-------|----------|154| kroki.io unreachable | Check internet; output .excalidraw only, inform user to export manually |155| fonttools/brotli not installed | Run `pip install fonttools brotli`; falls back to Chrome or system fonts |156| CJK text shows as boxes | Use `fontFamily: 5` so kroki embeds Xiaolai; ensure fonttools+brotli installed for text-to-path |157| Elements overlap | Increase spacing; use 200-300px horizontal gap |158| Too many elements | Break into multiple diagrams; suggest high-level + detail views |159160## PNG Backend Priority161162| Backend | Hand-drawn English | Hand-drawn CJK | Notes |163|---------|---|---|---|164| text-to-path + resvg | ✅ Excalifont | ✅ Xiaolai | Recommended. Extracts woff2 glyphs via fonttools, converts `<text>` → `<path>`. Fast, no browser. |165| Chrome headless | ✅ Excalifont | ✅ Xiaolai | Fallback. Renders @font-face natively but heavy (~500MB). |166| resvg (no fonttools) | ❌ System font | ❌ System font | Last resort. Ignores @font-face, uses system fonts. |167168## Limitations169170- Requires internet access (kroki.io for SVG rendering)171- Maximum recommended: 20 elements per diagram172- No embedded image support in auto-generation173- Hand-drawn roughness uses default settings