Skill · Published 2026-08-11

mermaid-to-drawio

Download mermaid-to-drawio.zip 100% test coverage Ported from none — standalone, see README's Provenance

A Claude Skill for the moment a Mermaid diagram needs to stop being text and become a real, editable draw.io (diagrams.net) file — not a screenshot, not a flattened image pasted into a doc.

What it does

Parses a Mermaid flowchart/graph or classDiagram directly and writes a real <mxGraphModel> document — draw.io’s actual native file format — with real mxCell vertices and edges, laid out by this script itself:

python3 mermaid_to_drawio.py diagram.mmd -o diagram.drawio   # write straight to a file
python3 mermaid_to_drawio.py diagram.mmd                      # XML to stdout
python3 mermaid_to_drawio.py -                                 # read Mermaid from stdin

Why not just paste it into draw.io’s own “Insert > Mermaid”? A web search before building this turned up exactly why not: the jgraph/drawio issue tracker documents that importer failing specifically for flowcharts and UML class diagrams — sometimes with an outright import error, sometimes by silently falling back to a flattened image instead of real editable shapes — plus a 50,000-character import ceiling and a Mermaid engine version pinned inside draw.io that lags upstream Mermaid syntax. This script never goes through that importer: it parses the Mermaid text itself and writes drawio’s own native XML format directly, so the result opens as a genuinely editable diagram every time.

Every flowchart shape delimiter Mermaid defines maps to a real mxgraph shape (a diamond is a real rhombus, a cylinder a real cylinder3, not a rectangle standing in for either); subgraph blocks become real draw.io containers, so dragging one moves its members with it; and every real Mermaid classDiagram relationship — inheritance, realization, composition, aggregation, association, dependency — decodes to the correct arrowhead from the actual operator characters, not a fixed lookup table.

Composes directly with this bundle’s own dependency-diagram skill — proven with a real fixture in this skill’s own test suite, not just described:

python3 dependency_diagram.py src/ --style block | python3 mermaid_to_drawio.py -

Where this came from

Like dependency-diagram before it, there’s no Mermaid-to-drawio conversion mechanism in PinkyAI’s own engine to port from — this is a direct request, scoped after a web search confirmed the problem it sidesteps was real and well-documented, not assumed. See the source bundle’s own README.md for the full provenance note and two real bugs its own composition test caught before shipping.

Honest scope

Two diagram kinds, by design: Mermaid flowchart/graph and classDiagram — every other Mermaid diagram kind (sequenceDiagram, stateDiagram, erDiagram, gantt, pie, and the rest) gets a clear, named error, not a silent misparse. Layout is this script’s own longest-path-from-sources layered layout, not draw.io’s or Mermaid’s — immediately readable and non-overlapping, not a claim of optimal compactness. A class box is one HTML-labeled rectangle, not draw.io’s native multi-compartment UML container. See the source’s own README for the complete list, including relationship multiplicities (parsed so they don’t break, not currently drawn) and parallelogram/trapezoid flowchart shapes (fall back to a plain rectangle).

Verification

197 tests, 100%+ statement coverage, run for real with coverage measured, not asserted — including a real fixture that pipes dependency-diagram’s own output through this converter and asserts valid, correctly-labeled draw.io XML comes out.

Preview the real source

Read straight out of this skill's own source directory, unedited — the exact bytes that ship inside mermaid-to-drawio.zip, not a rewritten excerpt. Switch tabs to read a file before downloading, or use Copy to paste it somewhere else.

Choose a file to preview

← Back to skills