Mermaid Diagram Cheat Sheet (Copy-Paste Ready)

Five production-tested Mermaid diagram patterns you can copy directly into READMEs, RFCs, and specs. All examples avoid common syntax pitfalls (quoting labels with punctuation, clean node IDs, valid arrow syntax).


1. Flowchart (Architecture & Decision Trees)

[Diagram]

2. Sequence Diagram (API & Auth Flows)

[Diagram]

3. Entity-Relationship Diagram (Database Schemas)

[Diagram]

4. State Diagram (Lifecycle & Workflows)

[Diagram]

5. Gantt Chart (Release & Migration Timeline)

[Diagram]

Quick Syntax Rules That Prevent 90% of Mermaid Errors

Pitfall Broken Example Safe Fix
Parentheses inside node labels A[API (v2)] A["API (v2)"]
Colons or slashes in edge labels A --> /v2/events B `A -->
Reserved word as node ID end[Finish] finish["Finish"]
Spaces in node IDs my node[Label] my_node["Label"]