Draw Io Diagram Generator
GitHubOfficialFirst committed by SriSatyaLokeshDistributed by GitHub
- Skill
- Tool integration
- Design and creative
- MIT
- Low risk
- Has scripts
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
The draw-io-diagram-generator skill enables the creation, modification, and validation of .drawio diagram files. It provides a structured approach to generating mxGraph XML, ensuring that files are immediately compatible with the draw.io VS Code extension and other draw.io platforms. The skill covers various diagram types including flowcharts, system architecture, sequence diagrams, ER diagrams, and UML class diagrams, offering templates and specific styling guidelines for each.
What it does
- Generates valid .drawio, .drawio.svg, and .drawio.png files.
- Provides templates for common diagram types like flowcharts and architecture.
- Applies consistent semantic styling and layout strategies.
- Validates XML structure to ensure immediate compatibility with draw.io tools.
- Supports editing existing diagrams by maintaining proper cell hierarchy and unique IDs.
- Includes helper scripts for shape insertion and file validation.
When to use it
- When you need to create a new flowchart, sequence, or architecture diagram.
- When you need to document system interactions or data models.
- When you need to programmatically update or modify an existing .drawio file.
- When you require a diagram file that is ready to open in the draw.io VS Code extension.
Advantages
- Ensures valid XML structure for seamless integration with draw.io.
- Standardizes diagram appearance through predefined semantic color palettes.
- Reduces manual effort by providing templates and automated validation.
- Maintains consistency across complex, multi-page diagrams.
Usage examples
- “Create a flowchart for a user login process and save it as login-flow.drawio.”
- The agent generates a .drawio file containing a start node, process steps for credential entry and validation, a decision diamond for success/failure, and end nodes, saved to the specified path.
- “Generate a 3-tier system architecture diagram for a web application.”
- The agent creates a .drawio file using swimlane containers to represent Client, API, and Database tiers, with correctly styled service boxes and connectors.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/github/draw-io-diagram-generator/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip draw-io-diagram-generator.zip -d .agents/skills
Documentation by SriSatyaLokesh
Draw.io Diagram Generator
This skill enables you to generate, edit, and validate draw.io (.drawio) diagram files with
correct mxGraph XML structure. All generated files open immediately in the
Draw.io VS Code extension
(hediet.vscode-drawio) without any manual fixes required. You can also open the files in the draw.io web app or desktop app if you prefer.
1. When to Use This Skill
Trigger phrases (load this skill when you see these)
"create a diagram", "draw a flowchart", "generate an architecture diagram"
"design a sequence diagram", "make a UML class diagram", "build an ER diagram"
"add a .drawio file", "update the diagram", "visualise the flow"
"document the architecture", "show the data model", "diagram the service interactions"
Any request to produce or modify a
.drawio,.drawio.svg, or.drawio.pngfile
Supported diagram types
| Diagram Type | Template Available | Description |
|---|---|---|
| Flowchart | assets/templates/flowchart.drawio | Process flows with decisions and branches |
| System Architecture | assets/templates/architecture.drawio | Multi-tier / layered service architecture |
| Sequence Diagram | assets/templates/sequence.drawio | Actor lifelines and timed message flows |
| ER Diagram | assets/templates/er-diagram.drawio | Database tables with relationships |
| UML Class Diagram | assets/templates/uml-class.drawio | Classes, interfaces, enums, relationships |
| Network Topology | (use shape library) | Routers, servers, firewalls, subnets |
| BPMN Workflow | (use shape library) | Business process events, tasks, gateways |
| Mind Map | (manual) | Central topic with radiating branches |
2. Prerequisites
If running with VS Code integration enabled, Install the drawio extension: draw.io VS Code extension —
hediet.vscode-drawio(extension id). Install with:ext install hediet.vscode-drawioSupported file extensions:
.drawio,.drawio.svg,.drawio.pngPython 3.8+ (optional) — for the validation and shape-insertion scripts in
scripts/
3. Step-by-Step Agent Workflow
Follow these steps in order for every diagram generation task.
Step 1 — Understand the Request
Ask or infer:
Diagram type — What kind of diagram? (flowchart, architecture, UML, ER, sequence, network...)
Entities / actors — What are the main components, actors, classes, or tables?
Relationships — How are they connected? What direction? What cardinality?
Output path — Where should the
.drawiofile be saved?Existing file — Are we creating new or editing an existing file?
If the request is ambiguous, infer the most sensible diagram type from context (e.g. "show the tables" → ER diagram, "show how the API call flows" → sequence diagram).
Step 2 — Select a Template or Start Fresh
Use a template when the diagram type matches one in
assets/templates/. Copy the template structure and replace placeholder values.Start fresh for novel layouts. Begin with the minimal valid skeleton:
<!-- Set modified="" to the current ISO 8601 timestamp when generating a new file -->
<mxfile host="Electron" modified="" version="26.0.0">
<diagram id="page-1" name="Page-1">
<mxGraphModel dx="1422" dy="762" grid="1" gridSize="10" guides="1"
tooltips="1" connect="1" arrows="1" fold="1"
page="1" pageScale="1" pageWidth="1169" pageHeight="827"
math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<!-- Your cells go here -->
</root>
</mxGraphModel>
</diagram>
</mxfile>Rule: ids
0and1are ALWAYS required and must be the first two cells. Never reuse them.
Step 3 — Plan the Layout
Before generating XML, sketch the logical placement:
Organise into rows or tiers (use swimlanes for layers)
Horizontal spacing: 40–60px between same-row shapes
Vertical spacing: 80–120px between tier rows
Standard shape size:
120x60px for process boxes,160x80px for swimlanesDefault canvas: A4 landscape =
1169 x 827px
Step 4 — Generate the mxGraph XML
Vertex cell (every shape):
<mxCell id="unique-id" value="Label"
style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;"
vertex="1" parent="1">
<mxGeometry x="100" y="100" width="120" height="60" as="geometry" />
</mxCell>Edge cell (every connector):
<mxCell id="edge-id" value="Label (optional)"
style="edgeStyle=orthogonalEdgeStyle;html=1;"
edge="1" source="source-id" target="target-id" parent="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>Critical rules:
Every cell id must be globally unique within the file
Every vertex must have an
mxGeometrychild withx,y,width,height,as="geometry"Every edge must have
sourceandtargetmatching existing vertex ids — exception: floating edges (e.g. sequence diagram lifelines) usesourcePoint/targetPointinside<mxGeometry>instead; see §4 Sequence DiagramEvery cell's
parentmust reference an existing cell idUse
html=1in style when the label contains HTML (<b>,<i>,<br>)Escape XML special characters in labels:
&=>&,<=><,>=>>
Step 5 — Apply Correct Styles
Use the standard semantic color palette for consistency:
| Purpose | fillColor | strokeColor |
|---|---|---|
| Primary / Info | #dae8fc | #6c8ebf |
| Success / Start | #d5e8d4 | #82b366 |
| Warning / Decision | #fff2cc | #d6b656 |
| Error / End | #f8cecc | #b85450 |
| Neutral | #f5f5f5 | #666666 |
| External / Partner | #e1d5e7 | #9673a6 |
Common style strings by diagram type:
# Rounded process box (flowchart)
rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;
# Decision diamond
rhombus;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;
# Start/End terminal
ellipse;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;
# Database cylinder
shape=mxgraph.flowchart.database;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;
# Swimlane container (tier)
swimlane;startSize=30;fillColor=#dae8fc;strokeColor=#6c8ebf;fontStyle=1;
# UML class box
swimlane;fontStyle=1;align=center;startSize=40;fillColor=#dae8fc;strokeColor=#6c8ebf;
# Interface / stereotype box
swimlane;fontStyle=3;align=center;startSize=40;fillColor=#f5f5f5;strokeColor=#666666;
# ER table container
shape=table;startSize=30;container=1;collapsible=1;childLayout=tableLayout;
# Orthogonal connector
edgeStyle=orthogonalEdgeStyle;html=1;
# ER relationship (crow's foot)
edgeStyle=entityRelationEdgeStyle;html=1;endArrow=ERmany;startArrow=ERone;See
references/style-reference.mdfor the complete style key catalog andreferences/shape-libraries.mdfor all shape library names.
Step 6 — Save and Validate
Write the file to the requested path with
.drawioextensionRun the validator (optional but recommended):
python .github/skills/draw-io-diagram-generator/scripts/validate-drawio.py <path-to-file.drawio>Tell the user how to open the file:
"Open
<filename>in VS Code — it will render automatically with the draw.io extension. You can use draw.io's web app or desktop app as well if you prefer."Provide a brief description of what is in the diagram so the user knows what to expect.
4. Diagram-Type Recipes
Flowchart
Key elements: Start (ellipse) => Process (rounded rectangle) => Decision (diamond) => End (ellipse)
<!-- Start node -->
<mxCell id="start" value="Start"
style="ellipse;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;"
vertex="1" parent="1">
<mxGeometry x="500" y="80" width="120" height="60" as="geometry" />
</mxCell>
<!-- Process -->
<mxCell id="p1" value="Process Step"
style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;"
vertex="1" parent="1">
<mxGeometry x="500" y="200" width="120" height="60" as="geometry" />
</mxCell>
<!-- Decision -->
<mxCell id="d1" value="Condition?"
style="rhombus;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;"
vertex="1" parent="1">
<mxGeometry x="460" y="320" width="200" height="100" as="geometry" />
</mxCell>
<!-- Arrow: start to p1 -->
<mxCell id="e1" value=""
style="edgeStyle=orthogonalEdgeStyle;html=1;"
edge="1" source="start" target="p1" parent="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>Architecture Diagram (3-tier)
Use swimlane containers for each tier. All service boxes are children of their swimlane.
<!-- Tier swimlane -->
<mxCell id="tier1" value="Client Layer"
style="swimlane;startSize=30;fillColor=#dae8fc;strokeColor=#6c8ebf;fontStyle=1;"
vertex="1" parent="1">
<mxGeometry x="60" y="100" width="1050" height="130" as="geometry" />
</mxCell>
<!-- Service inside tier (parent="tier1", coords are relative to tier) -->
<mxCell id="webapp" value="Web App"
style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;"
vertex="1" parent="tier1">
<mxGeometry x="80" y="40" width="120" height="60" as="geometry" />
</mxCell>Connectors between tiers use absolute coordinates with
parent="1".
Sequence Diagram
Key elements: Actors (top), Lifelines (dashed vertical lines), Activation boxes, Message arrows.
Lifelines:
edge="1"withendArrow=noneanddashed=1, no source/target — usesourcePoint/targetPointin geometrySynchronous message:
endArrow=block;endFill=1Return message:
endArrow=open;endFill=0;dashed=1Self-call: loop the edge via two Array points to the right and back
Minimal XML snippet:
<!-- Actor (stick figure) -->
<mxCell id="actorA" value="Client"
style="shape=mxgraph.uml.actor;pointerEvents=1;dashed=0;whiteSpace=wrap;html=1;aspect=fixed;"
vertex="1" parent="1">
<mxGeometry x="110" y="80" width="60" height="80" as="geometry" />
</mxCell>
<!-- Service box -->
<mxCell id="actorB" value="API Server"
style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;"
vertex="1" parent="1">
<mxGeometry x="480" y="100" width="160" height="60" as="geometry" />
</mxCell>
<!-- Lifeline — floating edge: uses sourcePoint/targetPoint, NOT source/target attributes -->
<mxCell id="lifA" value=""
style="edgeStyle=none;dashed=1;endArrow=none;"
edge="1" parent="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="140" y="160" as="sourcePoint" />
<mxPoint x="140" y="700" as="targetPoint" />
</mxGeometry>
</mxCell>
<!-- Activation box (thin rectangle on lifeline) -->
<mxCell id="actA1" value=""
style="fillColor=#dae8fc;strokeColor=#6c8ebf;"
vertex="1" parent="1">
<mxGeometry x="130" y="220" width="20" height="180" as="geometry" />
</mxCell>
<!-- Synchronous message -->
<mxCell id="msg1" value="POST /orders"
style="edgeStyle=elbowEdgeStyle;elbow=vertical;html=1;endArrow=block;endFill=1;"
edge="1" source="actA1" target="actorB" parent="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<!-- Return message (dashed) -->
<mxCell id="msg2" value="201 Created"
style="edgeStyle=elbowEdgeStyle;elbow=vertical;dashed=1;html=1;endArrow=open;endFill=0;"
edge="1" source="actorB" target="actA1" parent="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>Note: Lifelines are floating edges that use
sourcePoint/targetPointin<mxGeometry>instead ofsource/targetattributes. This is the standard draw.io pattern for sequence diagrams.
ER Diagram
Use shape=table containers with childLayout=tableLayout. Rows are shape=tableRow cells with portConstraint=eastwest. Columns inside each row are shape=partialRectangle.
Relationship arrows use edgeStyle=entityRelationEdgeStyle:
One-to-One:
startArrow=ERone;endArrow=ERoneOne-to-Many:
startArrow=ERone;endArrow=ERmanyMany-to-Many:
startArrow=ERmany;endArrow=ERmanyMandatory:
ERmandOne, Optional:ERzeroToOne
UML Class Diagram
Class boxes are swimlane containers. Attributes and methods are plain text cells. Dividers are zero-height swimlane children.
Arrow styles by relationship type:
| Relationship | Style String |
|---|---|
| Inheritance (extends) | edgeStyle=orthogonalEdgeStyle;html=1;endArrow=block;endFill=0; |
| Realization (implements) | edgeStyle=orthogonalEdgeStyle;dashed=1;html=1;endArrow=block;endFill=0; |
| Composition | edgeStyle=orthogonalEdgeStyle;html=1;startArrow=diamond;startFill=1;endArrow=none; |
| Aggregation | edgeStyle=orthogonalEdgeStyle;html=1;startArrow=diamond;startFill=0;endArrow=none; |
| Dependency | edgeStyle=orthogonalEdgeStyle;dashed=1;html=1;endArrow=open;endFill=0; |
| Association | edgeStyle=orthogonalEdgeStyle;html=1;endArrow=open;endFill=0; |
5. Multi-Page Diagrams
Add multiple <diagram> elements for complex systems:
<mxfile host="Electron" version="26.0.0">
<diagram id="overview" name="Overview">
<!-- overview mxGraphModel -->
</diagram>
<diagram id="detail" name="Detail View">
<!-- detail mxGraphModel -->
</diagram>
</mxfile>Each page has its own independent cell id namespace. The same id value can appear in different pages without conflict.
6. Editing Existing Diagrams
When modifying an existing .drawio file:
Read the file first to understand existing cell ids, positions, and parent hierarchy
Identify the target diagram page — by index or
nameattributeAssign new unique ids that do not collide with existing ids
Respect the container hierarchy — children of a swimlane use coordinates relative to their parent
Verify edges — after repositioning nodes, confirm edge source/target ids remain valid
Use scripts/add-shape.py to safely add a single shape without editing raw XML:
python .github/skills/draw-io-diagram-generator/scripts/add-shape.py docs/arch.drawio "New Service" 700 3807. Best Practices
Layout
Align shapes to the 10px grid (all coordinates divisible by 10)
Group related shapes inside swimlane containers
One diagram topic per page; use multi-page files for complex systems
Aim for 40 or fewer cells per page for readability
Labels
Add a title text cell (
text;strokeColor=none;fillColor=none;fontSize=18;fontStyle=1) at top of every pageAlways set
whiteSpace=wrap;html=1on vertex shapesKeep labels concise — 3 words or fewer per shape where possible
Style consistency
Use the semantic color palette from Section 3 Step 5 consistently across a project
Prefer
edgeStyle=orthogonalEdgeStylefor clean right-angle connectorsDo not inline arbitrary HTML in labels unless necessary
File naming
Use kebab-case:
order-service-flow.drawio,database-schema.drawioPlace diagrams alongside the code they document:
docs/orarchitecture/
8. Troubleshooting
| Problem | Likely Cause | Fix |
|---|---|---|
| File opens blank in VS Code | Missing id=0 or id=1 cell | Add both root cells before any other cells |
| Shape at wrong position | Child inside container — coords are relative | Check parent; adjust x/y relative to container |
| Edge not visible | source or target id does not match any vertex | Verify both ids exist exactly as written |
| Diagram shows "Compressed" | mxGraphModel is base64-encoded | Open in draw.io web, File > Export > XML (uncompressed) |
| Shape style not rendering | Typo in shape= name | Check references/shape-libraries.md for exact style string |
| Label shows escaped HTML | html=0 on a cell with HTML label | Add html=1; to the cell style |
| Container children overlap container edge | Container height too small | Increase container height in mxGeometry |
9. Validation Checklist
Before delivering any generated .drawio file, verify:
[ ] File starts with
<mxfile>root element[ ] Every
<diagram>has a non-emptyidattribute[ ]
<mxCell id="0" />is the first cell in every diagram[ ]
<mxCell id="1" parent="0" />is the second cell in every diagram[ ] All cell
idvalues are unique within each diagram[ ] Every vertex cell has
vertex="1"and a child<mxGeometry as="geometry">[ ] Every edge cell has
edge="1"and either: (a)source/targetpointing to existing vertex ids, or (b)<mxPoint as="sourcePoint">and<mxPoint as="targetPoint">in its<mxGeometry>(floating edge — used for sequence diagram lifelines)[ ] Every cell (except id=0) has a
parentpointing to an existing id[ ]
html=1is in the style for any label containing HTML tags[ ] XML is well-formed (no unclosed tags, no unescaped
&,<,>in attribute values)[ ] A title label cell exists at the top of each page
Run the automated validator:
python .github/skills/draw-io-diagram-generator/scripts/validate-drawio.py <file.drawio>10. Output Format
When delivering a diagram, always provide:
The
.drawiofile written to the requested pathA one-sentence summary of what the diagram shows
How to open it:
"Open
<filename>in VS Code — the draw.io extension will render it automatically. Or you can open it in the draw.io web app or desktop app if you prefer."How to edit it (if the user is likely to customise):
"Click any shape to select it. Double-click to edit the label. Drag to reposition."
Validation status — whether the validator script was run and passed
11. References
All companion files are in .github/skills/draw-io-diagram-generator/:
| File | Contents |
|---|---|
references/drawio-xml-schema.md | Complete mxfile / mxGraphModel / mxCell attribute reference, coordinate system, reserved cells, validation rules |
references/style-reference.md | All style keys with allowed values, vertex and edge style keys, shape catalog, semantic color palette |
references/shape-libraries.md | All shape library categories (General, Flowchart, UML, ER, Network, BPMN, Mockup, K8s) with style strings |
assets/templates/flowchart.drawio | Ready-to-use flowchart template |
assets/templates/architecture.drawio | 4-tier system architecture template |
assets/templates/sequence.drawio | 3-actor sequence diagram template |
assets/templates/er-diagram.drawio | 3-table ER diagram with crow's foot relationships |
assets/templates/uml-class.drawio | Interface + 2 classes + enum with relationship arrows |
scripts/validate-drawio.py | Python script to validate XML structure of any .drawio file |
scripts/add-shape.py | Python CLI to add a new shape to an existing diagram |
scripts/README.md | How to use the scripts with examples |
Files
- ATTRIBUTION.mdAdded by AutoGineer895 B
- LICENSELicence file added by AutoGineer1.0 KiB
- SKILL.md19.1 KiB
- assets/templates/architecture.drawio7.9 KiB
- assets/templates/er-diagram.drawio26.0 KiB
- assets/templates/flowchart.drawio4.5 KiB
- assets/templates/sequence.drawio7.1 KiB
- assets/templates/uml-class.drawio12.7 KiB
- references/drawio-xml-schema.md10.5 KiB
- references/shape-libraries.md12.8 KiB
- references/style-reference.md15.1 KiB
- scripts/.gitignore39 B
- scripts/README.md3.3 KiB
- scripts/add-shape.pyScript6.5 KiB
- scripts/validate-drawio.pyScript7.5 KiB
references/drawio-xml-schema.md
draw.io XML Schema Reference
Complete reference for the .drawio file format (mxGraph XML). Use this when generating, parsing, or validating diagram files.
Top-Level Structure
Every .drawio file is XML with this root structure:
<!-- Set modified to the current ISO 8601 timestamp when generating a new file -->
<mxfile host="Electron" modified=""
agent="draw.io" version="26.0.0" type="device">
<diagram id="<unique-id>" name="<Page Name>">
<mxGraphModel ...attributes...>
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<!-- All content cells here -->
</root>
</mxGraphModel>
</diagram>
</mxfile><mxfile> Attributes
| Attribute | Required | Default | Description |
|---|---|---|---|
host | No | "app.diagrams.net" | Origin editor ("Electron" for desktop/VS Code) |
modified | No | — | ISO 8601 timestamp |
agent | No | — | User agent string |
version | No | — | draw.io version |
type | No | "device" | Storage type |
<diagram> Attributes
| Attribute | Required | Description |
|---|---|---|
id | Yes | Unique page identifier (any string) |
name | Yes | Tab label shown in editor |
<mxGraphModel> Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
dx | int | 1422 | Scroll X offset |
dy | int | 762 | Scroll Y offset |
grid | 0/1 | 1 | Show grid |
gridSize | int | 10 | Grid snap size in px |
guides | 0/1 | 1 | Show alignment guides |
tooltips | 0/1 | 1 | Enable tooltips |
connect | 0/1 | 1 | Enable connection arrows on hover |
arrows | 0/1 | 1 | Show directional arrows |
fold | 0/1 | 1 | Enable group fold/collapse |
page | 0/1 | 1 | Show page boundary |
pageScale | float | 1 | Page zoom scale |
pageWidth | int | 1169 | Page width in px (A4 landscape) |
pageHeight | int | 827 | Page height in px (A4 landscape) |
math | 0/1 | 0 | Enable LaTeX math rendering |
shadow | 0/1 | 0 | Global shadow on shapes |
Common page sizes (px at 96dpi):
| Format | Width | Height |
|---|---|---|
| A4 landscape | 1169 | 827 |
| A4 portrait | 827 | 1169 |
| A3 landscape | 1654 | 1169 |
| Letter landscape | 1100 | 850 |
| Letter portrait | 850 | 1100 |
| Screen (16:9) | 1654 | 931 |
Reserved Cells (Always Required)
<mxCell id="0" /> <!-- Root cell — never omit, never add attributes -->
<mxCell id="1" parent="0" /> <!-- Default layer — all cells are children of this -->These two cells MUST be the first entries inside <root>. IDs 0 and 1 are reserved and must not be used for any other cell.
Vertex (Shape) Element
<mxCell
id="2"
value="Label Text"
style="rounded=1;whiteSpace=wrap;html=1;"
vertex="1"
parent="1">
<mxGeometry x="200" y="160" width="120" height="60" as="geometry" />
</mxCell><mxCell> Vertex Attributes
| Attribute | Required | Type | Description |
|---|---|---|---|
id | Yes | string | Unique identifier within this diagram |
value | Yes | string | Label text (HTML allowed if style has html=1) |
style | Yes | string | Semicolon-delimited key=value style string |
vertex | Yes | "1" | Must be "1" to declare this as a shape |
parent | Yes | string | Parent cell ID ("1" for default layer) |
<mxGeometry> Vertex Attributes
| Attribute | Required | Type | Description |
|---|---|---|---|
x | Yes | float | Left edge of shape (px from canvas origin) |
y | Yes | float | Top edge of shape (px from canvas origin) |
width | Yes | float | Shape width in px |
height | Yes | float | Shape height in px |
as | Yes | "geometry" | Always "geometry" |
Edge (Connector) Element
<mxCell
id="5"
value="Label"
style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;"
edge="1"
source="2"
target="3"
parent="1">
<mxGeometry relative="1" as="geometry" />
</mxCell><mxCell> Edge Attributes
| Attribute | Required | Type | Description |
|---|---|---|---|
id | Yes | string | Unique identifier |
value | Yes | string | Connector label (empty string for no label) |
style | Yes | string | Style string (see Edge Styles) |
edge | Yes | "1" | Must be "1" to declare as connector |
source | No | string | ID of source vertex |
target | No | string | ID of target vertex |
parent | Yes | string | Parent cell ID (usually "1") |
<mxGeometry> Edge Attributes
| Attribute | Required | Type | Description |
|---|---|---|---|
relative | No | "1" | Always "1" for edges |
as | Yes | "geometry" | Always "geometry" |
Edge with Label Offset
<mxGeometry x="-0.1" y="10" relative="1" as="geometry">
<mxPoint as="offset" />
</mxGeometry>The x on relative geometry moves the label along the edge (-1 to 1). y is perpendicular offset in px.
Edge with Manual Waypoints (Control Points)
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="340" y="80" />
<mxPoint x="340" y="200" />
</Array>
</mxGeometry>Multi-Page Diagrams
<mxfile>
<diagram id="page-1" name="Overview">
<mxGraphModel>...</mxGraphModel>
</diagram>
<diagram id="page-2" name="Detail">
<mxGraphModel>...</mxGraphModel>
</diagram>
</mxfile>Each <diagram> is a separate page/tab. Cell IDs are scoped to their own <diagram> — the same ID value can appear in different pages without conflict.
Layer Cells
Layers replace the default id="1" layer. Cells are assigned to a layer via parent:
<mxCell id="0" />
<mxCell id="1" value="Background" parent="0" /> <!-- layer 1 -->
<mxCell id="layer2" value="Services" parent="0" /> <!-- layer 2 -->
<mxCell id="layer3" value="Connectors" parent="0" /> <!-- layer 3 -->
<!-- Assign layer via parent attribute -->
<mxCell id="10" value="API" ... parent="layer2">
<mxGeometry ... />
</mxCell>Toggle layer visibility:
<mxCell id="layer2" value="Services" parent="0" visible="0" />Swimlane Container
<!-- Swimlane container -->
<mxCell id="swim1" value="Process" style="shape=pool;startSize=30;horizontal=1;"
vertex="1" parent="1">
<mxGeometry x="40" y="40" width="800" height="340" as="geometry" />
</mxCell>
<!-- Lane 1 (child of swimlane container) -->
<mxCell id="lane1" value="Customer" style="swimlane;startSize=30;"
vertex="1" parent="swim1">
<mxGeometry x="0" y="30" width="800" height="150" as="geometry" />
</mxCell>
<!-- Shape inside lane (child of lane) -->
<mxCell id="step1" value="Place Order" style="rounded=1;whiteSpace=wrap;html=1;"
vertex="1" parent="lane1">
<mxGeometry x="80" y="50" width="120" height="60" as="geometry" />
</mxCell>Key: Cells inside a swimlane have
parentset to the lane's ID, not"1".
Coordinates inside lanes are relative to the lane origin.
Group Cells
<!-- Invisible group container -->
<mxCell id="group1" value="" style="group;" vertex="1" parent="1">
<mxGeometry x="100" y="100" width="300" height="200" as="geometry" />
</mxCell>
<!-- Children relative to group origin -->
<mxCell id="child1" value="A" style="rounded=1;" vertex="1" parent="group1">
<mxGeometry x="20" y="20" width="100" height="60" as="geometry" />
</mxCell>HTML Labels
When html=1 is in the style, value can contain HTML:
<mxCell value="<b>OrderService</b><br><i>:8080</i>"
style="rounded=1;html=1;" vertex="1" parent="1">
<mxGeometry x="100" y="100" width="160" height="60" as="geometry" />
</mxCell>HTML must be XML-escaped:
<→<>→>&→&"→"
Common HTML tags supported: <b>, <i>, <u>, <br>, <font color="#hex">, <span style="...">, <hr/>
Tooltip / Metadata
<mxCell value="Service Name" tooltip="Handles order processing" style="..." vertex="1" parent="1">
<mxGeometry ... />
</mxCell>ID Generation Rules
| Rule | Detail |
|---|---|
IDs 0 and 1 | Reserved — always the root and default layer |
| All other IDs | Must be unique within their <diagram> |
| Safe pattern | Sequential integers starting at 2, or UUID strings |
| Cross-page | IDs do not need to be unique across different <diagram> pages |
Safe sequential ID example:
id="2", id="3", id="4", ...UUID-style example:
id="a1b2c3d4-e5f6-7890-abcd-ef1234567890"Coordinate System
Origin
(0, 0)is top-left of the canvasxincreases rightwardyincreases downwardAll units are pixels
Recommended Spacing
| Context | Value |
|---|---|
| Minimum gap between shapes | 40px |
| Comfortable gap | 80px |
| Swimlane inner padding | 20px |
| Page margin from edge | 40px |
| Connector routing clearance | 10px |
Minimal Valid .drawio File
<mxfile host="Electron" modified="2026-03-25T00:00:00.000Z" version="26.0.0">
<diagram id="main" name="Page-1">
<mxGraphModel dx="1422" dy="762" grid="1" gridSize="10" guides="1"
tooltips="1" connect="1" arrows="1" fold="1"
page="1" pageScale="1" pageWidth="1169" pageHeight="827"
math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
</root>
</mxGraphModel>
</diagram>
</mxfile>Validation Rules
Must Pass
[ ]
id="0"andid="1"cells always present as first two children of<root>[ ] No other cell uses
id="0"orid="1"[ ] All
idvalues are unique within each<diagram>[ ] Every
<mxCell>has exactly one<mxGeometry>child[ ]
<mxGeometry>hasas="geometry"attribute[ ] Vertex cells have
vertex="1", edge cells haveedge="1"[ ] Edge
source/targetIDs reference existing vertex IDs in the same diagram[ ] Swimlane children have
parentset to the swimlane/lane ID, not"1"[ ] HTML in
valueattributes is XML-escaped
Recommended
[ ] Shapes do not overlap unless intentional (use ≥40px gap)
[ ] Edge labels are short (≤4 words)
[ ] Layer cells have descriptive
valuenames[ ] All shapes fit within
pageWidth×pageHeightbounds
Requirements and compatibility
Written for: GitHub Copilot
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs Python, Needs Node.js
Security
What our scanner noticed· Low risk
- Scripts that your agent may run
This skill includes scripts that your agent may run. Read them before you use it.
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- First committed by
SriSatyaLokesh
- Publisher
- GitHub (Official)
- Distributed by
- GitHub
- Source
- github/awesome-copilot · skills/draw-io-diagram-generator · commit 797337f
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
- Contributors
- SriSatyaLokesh
AutoGineer is not affiliated with or endorsed by SriSatyaLokesh or GitHub.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download draw-io-diagram-generator.zip