How to convert existing diagrams to Mermaid syntax
If you've invested in Visio, Lucidchart, draw.io, or any proprietary diagramming tool, you've probably felt locked in. Converting those diagrams to Mermaid syntax isn't hard, but it does require a structured approach. This guide shows you how to audit a diagram, plan the conversion, and write clean, maintainable Mermaid.
Why convert to Mermaid?
Proprietary formats live in tool-specific files. Mermaid lives in plain text:
- Version control — diagrams diff cleanly in Git
- Portability — paste into GitHub, Notion, docs, emails
- No license friction — Mermaid is free and open
- Embedded in docs — live in READMEs, Confluence, or static sites
Converting is an investment that pays off as your team scales.
Step 1: Audit the diagram
Before you start typing, ask yourself:
- What diagram type is it? Flowchart, sequence, entity-relationship, state machine, class diagram, or something custom?
- How many nodes? 5–20 nodes convert smoothly; 50+ might split into multiple diagrams.
- Are there edge labels? Mermaid handles labels, but verify you need them.
- Any styling or metadata (colors, icons, layout hints) that matters to the content?
If styling is decorative, drop it. If it encodes meaning (red = error, green = success), you'll need to recreate it in Mermaid.
Step 2: Choose your Mermaid diagram type
This is the key decision. Visio might show the same shapes in multiple contexts.
| Your diagram | Use this type | Notes |
|---|---|---|
| Process / workflow / swimlanes | flowchart or flowchart LR | Directional graphs. Split lanes into subgraphs. |
| API calls / message sequence | sequenceDiagram | For time-ordered interactions. |
| Tables / entities / relationships | erDiagram | Foreign keys, cardinality. |
| Object hierarchy / inheritance | classDiagram | For OOP structures. |
| State transitions | stateDiagram | When state name is the key focus. |
| Gantt bars / timeline | ganttDiagram | For schedules and milestones. |
| Dependency tree / mind | mindmapDiagram | Radial hierarchies. |
Step 3: Build the node list
Open a text editor. Write down every node's ID and label:
A: Submit request
B: Validate input
C: Save to database
D: Send confirmation
E: Error handler
Keep IDs short (1–2 chars or concise words). Mermaid will use them as references.
Step 4: Map the edges
List every arrow, including its source, target, and label:
A → B (always)
B → C (if valid)
B → E (if invalid, label: "error")
C → D (always)
E → A (label: "retry")
This is where you'll catch implicit logic that the visual diagram obscured.
Step 5: Write the Mermaid
Start with the diagram declaration and nodes:
flowchart TD
A[Submit request]
B{Validate input}
C[Save to database]
D[Send confirmation]
E[Error handler]
A --> B
B -->|Valid| C
B -->|Invalid| E
C --> D
E -->|Retry| A
Tips:
- Use consistent node shapes (rectangles for steps, diamonds for decisions, rounded for start/end).
- Put node declarations at the top, edges below.
- Label edges only when the label adds meaning.
Step 6: Verify and refine
- Paste into MermaidCreator or mermaid.live.
- Check readability — Do the nodes flow logically? Are crossing lines minimal?
- Simplify — Can you remove or combine nodes?
- Add subgraphs if there are logical clusters (frontend, backend, database layer).
flowchart TD
subgraph Request
A[Submit request]
B{Validate}
end
subgraph Processing
C[Save to DB]
D[Send email]
end
subgraph Error
E[Log error]
end
A --> B
B -->|Valid| C
C --> D
B -->|Invalid| E
E -->|Retry| A
Common conversion gotchas
Cycles and loops: Mermaid handles them fine, but keep them visual. Use --> and point back to an earlier node.
Swimlanes: Visio swimlanes → Mermaid subgraphs. Each lane becomes a subgraph.
Styling: Mermaid's built-in styling is limited. If your diagram relies on colors or custom icons, focus on structure first and style later (or live with the defaults).
Large diagrams: If you're converting a 100-node diagram, consider splitting it. One diagram per "concept" is more readable than one massive one.
Tools to speed up conversion
- MermaidCreator — visual canvas. Drag-and-drop to build it, export as Mermaid code.
- draw.io → SVG — export your source diagram as SVG, study the structure, then manually build Mermaid.
- AI + prompt — describe the diagram in words, let Claude draft the Mermaid, then refine it in the editor.
FAQ
Q: Do I have to convert all my diagrams at once? A: No. Start with one. Once you see the value (diffs in PRs, embedding in docs), convert others gradually.
Q: My diagram has custom styling (brand colors, icons). Can Mermaid do that? A: Partially. Mermaid supports classes and basic color overrides, but not custom icons or full design flexibility. If styling is critical, keep the original tool for final export; use Mermaid for the structure.
Q: What if I have a diagram that doesn't fit any Mermaid type? A: You might need to rethink the structure, split it, or use a generic flowchart. If it's truly custom, Mermaid may not be the right fit — keep the original tool for that one.
Q: Can I automate diagram conversion? A: Partially. Tools like Graphviz DOT can be converted programmatically, but proprietary formats are locked. Manual conversion is more reliable for complex diagrams.
Ready to migrate? Try the editor — paste a simple diagram, redraw it in Mermaid, and see how quickly it comes together.
Related posts
Block diagrams for system architecture: boxes and flows in Mermaid
Sketch system architecture using Mermaid block diagrams—simple, text-based boxes and connections for design reviews, documentation, and onboarding.
Quadrant charts for prioritization: impact vs. effort in Mermaid
Use Mermaid quadrant charts to visualize impact-effort matrices, prioritization decisions, and portfolio analysis in text-based diagrams that live in Git.