excalidraw-studio
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseExcalidraw Studio
Excalidraw 工作室
Generate Excalidraw-format diagrams from natural language descriptions. Outputs JSON files that can be opened directly in Excalidraw (web, VS Code extension, or Obsidian plugin).
.excalidraw根据自然语言描述生成Excalidraw格式的图表。输出的.excalidraw JSON文件可直接在Excalidraw(网页端、VS Code扩展或Obsidian插件)中打开。
Workflow
工作流程
UNDERSTAND → CHOOSE TYPE → EXTRACT → GENERATE → SAVEUNDERSTAND → CHOOSE TYPE → EXTRACT → GENERATE → SAVEStep 1: Understand the Request
步骤1:理解需求
Analyze the user's description to determine:
- Diagram type — Use the decision matrix below
- Key elements — Entities, steps, concepts, actors
- Relationships — Flow direction, connections, hierarchy
- Complexity — Number of elements (target: under 20 for clarity)
分析用户的描述,确定:
- 图表类型 — 使用下方的决策矩阵
- 核心元素 — 实体、步骤、概念、参与者
- 关系 — 流向、连接、层级
- 复杂度 — 元素数量(建议不超过20个以保证清晰度)
Step 2: Choose the Diagram Type and Visual Mode
步骤2:选择图表类型与视觉模式
Diagram type:
| User Intent | Diagram Type | Keywords |
|---|---|---|
| Process flow, steps | Flowchart | "workflow", "process", "steps" |
| Connections, dependencies | Relationship | "relationship", "connections", "dependencies" |
| Concept hierarchy | Mind Map | "mind map", "concepts", "breakdown" |
| System design | Architecture | "architecture", "system", "components" |
| Data movement | Data Flow (DFD) | "data flow", "data processing" |
| Cross-functional processes | Swimlane | "business process", "swimlane", "actors" |
| Object-oriented design | Class Diagram | "class", "inheritance", "OOP" |
| Interaction sequences | Sequence Diagram | "sequence", "interaction", "messages" |
| Database design | ER Diagram | "database", "entity", "data model" |
Visual mode — decide upfront and apply consistently to all elements:
| Mode | | | When to use |
|---|---|---|---|
| Sketch | | | Default — informal, approachable, Excalidraw-native |
| Clean | | | Executive presentations, formal specs |
| Mixed | zones: | | Architecture diagrams (structural zones + sketchy shapes) |
图表类型:
| 用户意图 | 图表类型 | 关键词 |
|---|---|---|
| 流程步骤 | 流程图 | “工作流”“流程”“步骤” |
| 关联与依赖 | 关系图 | “关系”“连接”“依赖” |
| 概念层级 | 思维导图 | “思维导图”“概念”“分解” |
| 系统设计 | 架构图 | “架构”“系统”“组件” |
| 数据流转 | 数据流图(DFD) | “数据流”“数据处理” |
| 跨职能流程 | 泳道图 | “业务流程”“泳道”“参与者” |
| 面向对象设计 | 类图 | “类”“继承”“OOP” |
| 交互序列 | 序列图 | “序列”“交互”“消息” |
| 数据库设计 | ER图 | “数据库”“实体”“数据模型” |
视觉模式 — 提前确定并统一应用于所有元素:
| 模式 | | | 适用场景 |
|---|---|---|---|
| 手绘风格 | | | 默认选项 — 非正式、亲切,Excalidraw原生风格 |
| 简洁风格 | | | 高管汇报、正式规格文档 |
| 混合风格 | 区域: | | 架构图(结构化区域 + 手绘风格图形) |
Step 3: Extract Structured Information
步骤3:提取结构化信息
Extract the key components based on diagram type. For each type, identify:
- Nodes/entities — What are the boxes/shapes?
- Connections — What connects to what, and with what label?
- Hierarchy — What contains what, what comes before what?
- Decision points — Where does the flow branch?
For detailed extraction guidelines per diagram type, read .
references/element-types.md根据图表类型提取核心组件。针对每种类型,需明确:
- 节点/实体 — 哪些是方框/图形?
- 连接关系 — 元素间如何连接,标签是什么?
- 层级结构 — 包含关系、先后顺序?
- 决策点 — 流程在何处分支?
如需了解各图表类型的详细提取指南,请阅读。
references/element-types.mdStep 4: Generate the Excalidraw JSON
步骤4:生成Excalidraw JSON
CRITICAL: Read before generating your first diagram. It contains the correct element format, text container model, and binding system.
references/excalidraw-schema.mdKey rules for generation:
-
Text inside shapes — Useon the shape and a separate text element with
boundElements. Never use acontainerIdshorthand:labeljson[ { "id": "step-1", "type": "rectangle", "x": 100, "y": 100, "width": 200, "height": 80, "boundElements": [{ "type": "text", "id": "text-step-1" }] }, { "id": "text-step-1", "type": "text", "x": 130, "y": 128, "width": 140, "height": 24, "text": "My Step", "originalText": "My Step", "fontSize": 20, "fontFamily": 5, "textAlign": "center", "verticalAlign": "middle", "containerId": "step-1", "lineHeight": 1.25, "roundness": null } ] -
Arrow labels — Also use+ separate text element with
boundElements. Never use acontainerIdshorthand on arrows:labeljson[ { "id": "arrow-1", "type": "arrow", "x": 100, "y": 150, "points": [[0, 0], [200, 0]], "boundElements": [{ "type": "text", "id": "text-arrow-1" }] }, { "id": "text-arrow-1", "type": "text", "x": 160, "y": 132, "width": 80, "height": 18, "text": "sends data", "originalText": "sends data", "fontSize": 14, "fontFamily": 5, "textAlign": "center", "verticalAlign": "middle", "containerId": "arrow-1", "lineHeight": 1.25, "roundness": null } ] -
Arrow bindings — Use/
startBinding(notendBinding/start). Connected shapes must list the arrow in theirend:boundElementsjson{ "id": "shape-1", "boundElements": [ { "type": "text", "id": "text-shape-1" }, { "type": "arrow", "id": "arrow-1" } ] }json{ "id": "arrow-1", "type": "arrow", "startBinding": { "elementId": "shape-1", "focus": 0, "gap": 1 }, "endBinding": { "elementId": "shape-2", "focus": 0, "gap": 1 } } -
Element order for z-index — Always declare shapes first, arrows second, text elements last. This guarantees text renders on top and is never obscured by arrows or other shapes.
-
Positioning — Use grid-aligned coordinates (multiples of 20px when). Leave 200-300px horizontal gap, 100-150px vertical gap between elements.
gridSize: 20 -
Unique IDs — Every element must have a unique. Use descriptive IDs like
id,"step-1","decision-valid","arrow-1-to-2"."text-step-1" -
Colors — Use a consistent palette:
Role Color Hex Primary entities Light blue #a5d8ffProcess steps Light green #b2f2bbImportant/Central Yellow #ffd43bWarnings/Errors Light red #ffc9c9Secondary Cyan #96f2d7Default stroke Dark #1e1e1e
重要提示:生成第一张图表前,请务必阅读。该文档包含正确的元素格式、文本容器模型和绑定系统。
references/excalidraw-schema.md生成的核心规则:
-
图形内文本 — 在图形上使用,并创建单独的文本元素设置
boundElements。切勿使用containerId简写:labeljson[ { "id": "step-1", "type": "rectangle", "x": 100, "y": 100, "width": 200, "height": 80, "boundElements": [{ "type": "text", "id": "text-step-1" }] }, { "id": "text-step-1", "type": "text", "x": 130, "y": 128, "width": 140, "height": 24, "text": "My Step", "originalText": "My Step", "fontSize": 20, "fontFamily": 5, "textAlign": "center", "verticalAlign": "middle", "containerId": "step-1", "lineHeight": 1.25, "roundness": null } ] -
箭头标签 — 同样使用+ 单独的文本元素设置
boundElements。切勿在箭头上使用containerId简写:labeljson[ { "id": "arrow-1", "type": "arrow", "x": 100, "y": 150, "points": [[0, 0], [200, 0]], "boundElements": [{ "type": "text", "id": "text-arrow-1" }] }, { "id": "text-arrow-1", "type": "text", "x": 160, "y": 132, "width": 80, "height": 18, "text": "sends data", "originalText": "sends data", "fontSize": 14, "fontFamily": 5, "textAlign": "center", "verticalAlign": "middle", "containerId": "arrow-1", "lineHeight": 1.25, "roundness": null } ] -
箭头绑定 — 使用/
startBinding(而非endBinding/start)。被连接的图形必须在其end中列出该箭头:boundElementsjson{ "id": "shape-1", "boundElements": [ { "type": "text", "id": "text-shape-1" }, { "type": "arrow", "id": "arrow-1" } ] }json{ "id": "arrow-1", "type": "arrow", "startBinding": { "elementId": "shape-1", "focus": 0, "gap": 1 }, "endBinding": { "elementId": "shape-2", "focus": 0, "gap": 1 } } -
元素层级顺序 — 始终先声明图形,再声明箭头,最后声明文本元素。这样可以确保文本显示在最上层,不会被箭头或其他图形遮挡。
-
定位 — 使用网格对齐的坐标(当时,坐标为20px的倍数)。元素间保留200-300px的水平间距,100-150px的垂直间距。
gridSize: 20 -
唯一ID — 每个元素必须有唯一的。使用描述性ID,如
id、"step-1"、"decision-valid"、"arrow-1-to-2"。"text-step-1" -
颜色 — 使用统一的调色板:
角色 颜色 十六进制值 主要实体 浅蓝色 #a5d8ff流程步骤 浅绿色 #b2f2bb重要/核心元素 黄色 #ffd43b警告/错误 浅红色 #ffc9c9次要元素 青色 #96f2d7默认描边 深色 #1e1e1e
Step 5: Save and Present
步骤5:保存与呈现
-
Save as
<descriptive-name>.excalidraw -
Provide a summary:
Created: user-workflow.excalidraw Type: Flowchart Elements: 7 shapes, 6 arrows, 1 title Total: 14 elements To view: 1. Visit https://excalidraw.com → Open → drag and drop the file 2. Or use the Excalidraw VS Code extension 3. Or open in Obsidian with the Excalidraw plugin
-
保存为
<描述性名称>.excalidraw -
提供摘要:
Created: user-workflow.excalidraw Type: Flowchart Elements: 7 shapes, 6 arrows, 1 title Total: 14 elements To view: 1. Visit https://excalidraw.com → Open → drag and drop the file 2. Or use the Excalidraw VS Code extension 3. Or open in Obsidian with the Excalidraw plugin
Templates
模板
Pre-built templates are available in for quick starting points. Use these when the diagram type matches — they provide correct structure and styling:
assets/| Template | File |
|---|---|
| Flowchart | |
| Relationship | |
| Mind Map | |
| Data Flow (DFD) | |
| Swimlane | |
| Class Diagram | |
| Sequence Diagram | |
| ER Diagram | |
Read a template when creating that diagram type for the first time. Use its structure as a base, then modify elements to match the user's request.
assets/| 模板 | 文件 |
|---|---|
| 流程图 | |
| 关系图 | |
| 思维导图 | |
| 数据流图(DFD) | |
| 泳道图 | |
| 类图 | |
| 序列图 | |
| ER图 | |
首次创建对应类型的图表时,请参考模板。以模板结构为基础,修改元素以匹配用户需求。
Icon Libraries
图标库
For professional architecture diagrams with service icons (AWS, GCP, Azure, etc.), icon libraries can be set up. Read when:
references/icon-libraries.md- User requests an AWS/cloud architecture diagram
- User mentions wanting specific service icons
- You need to check if icon libraries are available
如需在专业架构图中使用服务图标(AWS、GCP、Azure等),可配置图标库。当出现以下情况时,请阅读:
references/icon-libraries.md- 用户要求创建AWS/云架构图
- 用户提及需要特定服务图标
- 你需要确认图标库是否可用
Best Practices
最佳实践
Element Count
元素数量
| Diagram Type | Recommended | Maximum |
|---|---|---|
| Flowchart steps | 3-10 | 15 |
| Relationship entities | 3-8 | 12 |
| Mind map branches | 4-6 | 8 |
| Sub-topics per branch | 2-4 | 6 |
If the user's request exceeds maximum, suggest breaking into multiple diagrams:
"Your request includes 15 components. For clarity, I recommend: (1) High-level architecture diagram with 6 main components, (2) Detailed sub-diagrams for each subsystem. Want me to start with the high-level view?"
| 图表类型 | 推荐数量 | 最大数量 |
|---|---|---|
| 流程图步骤 | 3-10 | 15 |
| 关系图实体 | 3-8 | 12 |
| 思维导图分支 | 4-6 | 8 |
| 每个分支的子主题 | 2-4 | 6 |
如果用户的需求超过最大数量,建议拆分为多个图表:
“你的需求包含15个组件。为保证清晰度,我建议:(1) 包含6个主要组件的高层级架构图,(2) 每个子系统的详细子图。需要我先从高层级视图开始吗?”
Layout
布局
- Flow direction: Left-to-right for processes, top-to-bottom for hierarchies
- Spacing: 200-300px horizontal, 100-150px vertical between elements
- Grid alignment: Position on multiples of 20px for clean alignment
- Margins: Minimum 50px from canvas edge
- Text sizing: 28-36px titles, 18-22px labels, 14-16px annotations
- Font: Use (Excalifont) for hand-drawn consistency. Fallback to
fontFamily: 5(Virgil) if 5 is not supported.1 - Background zones: For architecture diagrams, add semi-transparent dashed zone rectangles (,
opacity: 35,strokeStyle: "dashed") as the first elements in the array to create visual grouping regions. Seeroughness: 0→ Background Zones.references/excalidraw-schema.md - Element order: zones first → shapes → arrows → text elements (ensures correct z-index and text always renders on top)
- 流向:流程类图表从左到右,层级类图表从上到下
- 间距:元素间水平间距200-300px,垂直间距100-150px
- 网格对齐:定位在20px的倍数坐标上,保证对齐整齐
- 边距:画布边缘至少保留50px边距
- 文本尺寸:标题28-36px,标签18-22px,注释14-16px
- 字体:使用(Excalifont)保证手绘风格一致性。如果不支持, fallback到
fontFamily: 5(Virgil)。1 - 背景区域:对于架构图,在数组最前面添加半透明虚线区域矩形(,
opacity: 35,strokeStyle: "dashed"),创建视觉分组区域。请参考roughness: 0→ 背景区域。references/excalidraw-schema.md - 元素顺序:区域 → 图形 → 箭头 → 文本元素(确保文本始终在最上层)
Common Mistakes to Avoid
需避免的常见错误
- ❌ Using shorthand on shapes or arrows — not supported by the Excalidraw parser
label: { text: "..." } - ❌ Putting directly on shape elements without
textcontainerId - ❌ Using /
startfor arrow bindings — useend/startBindingwithendBinding/elementId/focusgap - ❌ Forgetting to add arrows to their connected shapes' arrays
boundElements - ❌ Omitting ,
originalText,lineHeight, orautoResizefrom text elements inside containersbackgroundColor: "transparent" - ❌ Omitting required base properties (,
angle,strokeStyle,opacity,groupIds,frameId,index,isDeleted,seed,version,versionNonce,updated,link) — elements will not renderlocked - ❌ Missing at the top level of the JSON
"files": {} - ❌ Using on ellipses — ellipses must use
roundness: { "type": 3 }roundness: null - ❌ Missing ,
lastCommittedPoint,startArrowheadon arrowsendArrowhead - ❌ Declaring text elements before arrows — text renders underneath and gets obscured
- ❌ Floating arrows without bindings (won't move with shapes)
- ❌ Overlapping elements (increase spacing)
- ❌ Inconsistent color usage (define palette upfront)
- ❌ Too many elements on one diagram (break into sub-diagrams)
- ❌ 在图形或箭头上使用简写 — Excalidraw解析器不支持
label: { text: "..." } - ❌ 在图形元素上直接添加而不设置
textcontainerId - ❌ 使用/
start进行箭头绑定 — 请使用带end/elementId/focus的gap/startBindingendBinding - ❌ 忘记在被连接图形的数组中添加箭头
boundElements - ❌ 容器内的文本元素遗漏、
originalText、lineHeight或autoResizebackgroundColor: "transparent" - ❌ 遗漏必填基础属性(、
angle、strokeStyle、opacity、groupIds、frameId、index、isDeleted、seed、version、versionNonce、updated、link) — 元素将无法渲染locked - ❌ 顶层JSON遗漏
"files": {} - ❌ 在椭圆上使用— 椭圆必须使用
roundness: { "type": 3 }roundness: null - ❌ 箭头上遗漏、
lastCommittedPoint、startArrowheadendArrowhead - ❌ 在箭头之前声明文本元素 — 文本会被遮挡在箭头下方
- ❌ 未绑定的浮动箭头(无法随图形移动)
- ❌ 元素重叠(增加间距)
- ❌ 颜色使用不一致(提前定义调色板)
- ❌ 单张图表元素过多(拆分为子图)
Validation Checklist
验证清单
Before delivering the diagram, verify:
- All elements have unique IDs
- Every element has ALL required base properties: ,
angle,strokeStyle,opacity,groupIds,frameId,index,isDeleted,link,locked,seed,version,versionNonceupdated - values are assigned in order (
index,"a0", …) with text elements getting higher values than shapes/arrows"a1" - Top-level JSON includes
"files": {} - Shapes with text use + separate text element with
boundElementscontainerId - Text elements inside containers have ,
containerId,originalText,lineHeight: 1.25,autoResize: true,roundness: nullbackgroundColor: "transparent" - Arrows use /
startBinding(withendBinding,elementId,focus) when connecting shapes, plusgap,lastCommittedPoint: null,startArrowhead: nullendArrowhead: "arrow" - Connected shapes list the arrow in their arrays
boundElements - Element order: shapes → arrows → text elements (text always on top)
- Ellipses use (not
roundness: null){ "type": 3 } - Coordinates prevent overlapping (check spacing)
- Text is readable (font size 16+)
- Colors follow consistent scheme
- File is valid JSON
- Element count is reasonable (<20 for clarity)
交付图表前,请验证:
- 所有元素都有唯一ID
- 每个元素都包含所有必填基础属性:、
angle、strokeStyle、opacity、groupIds、frameId、index、isDeleted、link、locked、seed、version、versionNonceupdated - 值按顺序分配(
index、"a0"……),文本元素的"a1"值高于图形/箭头index - 顶层JSON包含
"files": {} - 带文本的图形使用+ 带
boundElements的独立文本元素containerId - 容器内的文本元素包含、
containerId、originalText、lineHeight: 1.25、autoResize: true、roundness: nullbackgroundColor: "transparent" - 连接图形的箭头使用/
startBinding(带endBinding、elementId、focus),同时包含gap、lastCommittedPoint: null、startArrowhead: nullendArrowhead: "arrow" - 被连接的图形在其数组中列出该箭头
boundElements - 元素顺序:图形 → 箭头 → 文本元素(文本始终在最上层)
- 椭圆使用(而非
roundness: null){ "type": 3 } - 坐标避免元素重叠(检查间距)
- 文本可读性良好(字体大小16+)
- 颜色遵循统一方案
- 文件是有效的JSON
- 元素数量合理(少于20个以保证清晰度)
Troubleshooting
故障排除
| Issue | Solution |
|---|---|
| Text not showing in shapes | Use |
| Text hidden behind arrows | Move text elements to end of |
| Arrows don't move with shapes | Use |
| Shape not moving with arrows | Add the arrow to the shape's |
| Elements overlap | Increase spacing between coordinates |
| Text doesn't fit | Increase shape width or reduce font size |
| Too many elements | Break into multiple diagrams |
| Colors look inconsistent | Define color palette upfront, apply consistently |
| 问题 | 解决方案 |
|---|---|
| 图形内文本不显示 | 使用 |
| 文本被箭头遮挡 | 将文本元素移至 |
| 箭头无法随图形移动 | 使用带 |
| 图形无法随箭头移动 | 将箭头添加到图形的 |
| 元素重叠 | 增加坐标间距 |
| 文本无法容纳 | 增加图形宽度或减小字体大小 |
| 元素过多 | 拆分为多个图表 |
| 颜色不一致 | 提前定义调色板并统一应用 |
Limitations
局限性
- Complex curves are simplified to straight/basic curved lines
- Hand-drawn roughness is set to default (1)
- No embedded images in auto-generation (use icon libraries for service icons)
- Maximum recommended: 20 elements per diagram for clarity
- No automatic collision detection — use spacing guidelines
- 复杂曲线会简化为直线/基础曲线
- 手绘粗糙度默认设置为1
- 自动生成中不支持嵌入图片(使用图标库添加服务图标)
- 为保证清晰度,单张图表最多推荐20个元素
- 无自动碰撞检测 — 请遵循间距指南