Visio Draw.io SVG Diagrams
Use this skill for Visio-safe architecture diagrams. Prefer a .drawio source as the editable master, then generate SVG from that master.
Core Workflow
- Create or repair the
.drawiofile first. - Keep
.drawiouncompressed and inline:
- Use<mxfile><diagram><mxGraphModel>...</mxGraphModel></diagram></mxfile>.
- Do not put raw XML as text inside<diagram>.
- Do not use base64/deflate unless you are using draw.io's own exporter. - For stable line placement, use fixed point edges:
- Edge cells should use<mxGeometry relative="1" as="geometry">.
- Add<mxPoint ... as="sourcePoint"/>and<mxPoint ... as="targetPoint"/>.
- Avoid relying onsource/targetauto-routing when the line layout must match a reference drawing. - Put elements in this order:
- root cells0and1
- title and layer/background rectangles
- edges and edge labels
- device/component boxes - Generate SVG from
.drawiowithscripts/drawio_to_svg.py. - Validate both files before handing them off.
Use The Script
Run:
python <skill-dir>/scripts/drawio_to_svg.py input.drawio output.svg
The script reads inline draw.io XML and emits SVG with:
- fixed point edges copied from draw.io
- separate label text
clipPathper box so text cannot spill outside frames- conservative text wrapping for mixed Chinese/English labels
- UTF-8 output
If the input .drawio is compressed/base64 or lacks inline mxGraphModel, open it in draw.io and export as uncompressed XML, or repair it manually.
Validation Checklist
Before final delivery:
- Parse
.drawioand confirmdiagramhas anmxGraphModelchild and empty text. - Confirm every
mxGeometryusesas="geometry", notas_="geometry". - Confirm important Chinese labels still appear when reading files as UTF-8.
- Confirm SVG parses as XML.
- Render SVG through a browser or image pipeline and inspect:
- no broken image icon
- no text outside boxes
- labels do not cover critical line endpoints
- lines match the
.drawiolayout
Use references/compatibility.md for common failures and fixes.