All posts
MermaidMigrationTutorials

How to convert existing diagrams to Mermaid syntax

5 min readThe MermaidCreator team

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:

  1. What diagram type is it? Flowchart, sequence, entity-relationship, state machine, class diagram, or something custom?
  2. How many nodes? 5–20 nodes convert smoothly; 50+ might split into multiple diagrams.
  3. Are there edge labels? Mermaid handles labels, but verify you need them.
  4. 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 diagramUse this typeNotes
Process / workflow / swimlanesflowchart or flowchart LRDirectional graphs. Split lanes into subgraphs.
API calls / message sequencesequenceDiagramFor time-ordered interactions.
Tables / entities / relationshipserDiagramForeign keys, cardinality.
Object hierarchy / inheritanceclassDiagramFor OOP structures.
State transitionsstateDiagramWhen state name is the key focus.
Gantt bars / timelineganttDiagramFor schedules and milestones.
Dependency tree / mindmindmapDiagramRadial 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

  1. Paste into MermaidCreator or mermaid.live.
  2. Check readability — Do the nodes flow logically? Are crossing lines minimal?
  3. Simplify — Can you remove or combine nodes?
  4. 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