Mermaid Reference Manual (Hybrid Edition)

Mermaid Reference Manual (Hybrid Edition)

A practical, readable guide to Mermaid 10.9.5

Diagrams as code · Live playground · Themeable editors

1. What Mermaid Is

Reference + Playground
Plain text in, rich diagrams out—versionable, searchable, themeable.

Mermaid is a “diagrams as code” tool. You write plain text, and Mermaid renders diagrams such as:

  • Flowcharts, sequence diagrams, class diagrams, and state machines
  • ER diagrams, journey diagrams, Gantt charts, pies, timelines, and mindmaps

2. Setup & Initialization

HTML · Markdown · SPA
CDN Global init Per-diagram overrides

2.1. Include the CDN Script

<script src="https://unpkg.com/mermaid@10.9.5/dist/mermaid.min.js"></script>

2.2. Global Initialization

<script>
mermaid.initialize({
  startOnLoad: true,
  theme: "dark"
});
</script>

3. Diagram Types

Gallery

3.1. Flowchart

flowchart LR A[Start] --> B{Decision?} B -->|Yes| C[Continue] B -->|No| D[Stop]

3.2. Sequence Diagram

sequenceDiagram actor User participant Browser participant Server User->>Browser: Open page Browser->>Server: Request data Server-->>Browser: JSON response Browser-->>User: Render UI

3.3. Class Diagram

classDiagram class User { +string name +login() } class Session { +string token } User --> Session : creates

3.4. State Diagram

stateDiagram-v2 [*] --> Idle Idle --> Running : start() Running --> Idle : stop()

3.5. ER Diagram

erDiagram USER ||--o{ ORDER : places ORDER ||--|{ ITEM : contains

3.6. Journey Diagram

journey title User Journey section Discover Finds site: 4 Reads docs: 5 section Use Tries feature: 3 Fixes error: 2

3.7. Gantt Chart

gantt dateFormat YYYY-MM-DD title Project Plan section Phase 1 Setup :done, p1, 2024-01-01, 3d Build :active, p2, 2024-01-04, 5d

3.8. Pie Chart

pie showData title Usage Breakdown "Docs" : 40 "UI" : 30 "Backend" : 20 "Other" : 10

3.9. Timeline

timeline title Release Timeline 2024-01 : Alpha 2024-03 : Beta 2024-06 : Launch

3.10. Mindmap

mindmap root((Project)) Planning Research Requirements Build Frontend Backend Deploy Testing Release

4. Mermaid Editor Components

Component library

Flowchart Editor

Preset snippets, theme-aware colors, live preview, SVG export.
flowchart LR A[Start] --> B{Decision?} B -->|Yes| C[Continue] B -->|No| D[Stop]

5. Customization Lab

Hands-on

Flowchart Lab

Branching logic, decisions, and paths.
flowchart LR A[Start] --> B{Decision?} B -->|Yes| C[Continue] B -->|No| D[Stop]

Sequence Lab

Calls between actors and services.
sequenceDiagram actor User participant Browser participant Server User->>Browser: Open page Browser->>Server: Request data Server-->>Browser: JSON response Browser-->>User: Render UI

Class Diagram Lab

Types, methods, and relationships.
classDiagram class User { +string name +login() } class Session { +string token } User --> Session : creates

State Diagram Lab

States, transitions, and events.
stateDiagram-v2 [*] --> Idle Idle --> Running : start() Running --> Idle : stop()

ER Diagram Lab

Entities, relationships, and cardinality.
erDiagram USER ||--o{ ORDER : places ORDER ||--|{ ITEM : contains

Journey Lab

User journeys and experience scores.
journey title User Journey section Discover Finds site: 4 Reads docs: 5 section Use Tries feature: 3 Fixes error: 2

Gantt Lab

Timelines, phases, and durations.
gantt dateFormat YYYY-MM-DD title Project Plan section Phase 1 Setup :done, p1, 2024-01-01, 3d Build :active, p2, 2024-01-04, 5d

Pie Lab

Quick breakdowns and proportions.
pie showData title Usage Breakdown "Docs" : 40 "UI" : 30 "Backend" : 20 "Other" : 10

Timeline Lab

Releases, milestones, and history.
timeline title Release Timeline 2024-01 : Alpha 2024-03 : Beta 2024-06 : Launch

Mindmap Lab

Ideas, branches, and structure.
mindmap root((Project)) Planning Research Requirements Build Frontend Backend Deploy Testing Release

6. Quick Reference

Cheat sheet

Core diagram keywords:

  • flowchart LR, sequenceDiagram, classDiagram, stateDiagram-v2
  • erDiagram, journey, gantt, pie, timeline, mindmap

End of mermaid_reference_manual.html · Live generators + SVG export for every diagram type.

Comments

Popular posts from this blog