Mermaid Syntax Cheat Sheet
Quick reference for all Mermaid diagram types. Copy any snippet and paste it into the editor.
Flowchart
Full guide →Top-down flow
flowchart TD
A --> B --> CLeft-right flow
flowchart LR
A --> B --> CRectangle node
A[Text]Rounded node
A(Text)Stadium node
A([Text])Diamond (decision)
A{Text}Hexagon
A{{Text}}Circle
A((Text))Arrow
A --> BArrow with label
A -->|label| BDotted arrow
A -.-> BThick arrow
A ==> BSubgraph
subgraph Title
A --> B
endSequence Diagram
Full guide →Solid arrow
A->>B: MessageDashed arrow
A-->>B: ResponseSolid cross
A-xB: FailedParticipant alias
participant A as AliceActor
actor U as UserActivation
activate A
...
deactivate ANote
Note over A,B: TextLoop
loop Every minute
A->>B: ping
endAlt / else
alt Success
A->>B: ok
else Error
A->>B: fail
endParallel
par Task 1
A->>B: msg
and Task 2
A->>C: msg
endER Diagram
Full guide →Entity with attrs
USER {
uuid id PK
string email UK
string name
}One to many
USER ||--o{ ORDER : "places"One to one
USER ||--|| PROFILE : "has"Many to many
STUDENT }o--o{ COURSE : "enrolls"Primary key
string id PKForeign key
uuid user_id FKUnique key
string email UKComment
string name "Display name"Identifying rel
A ||--|{ B : containsNon-identifying rel
A ||..o{ B : referencesClass Diagram
Full guide →Class
class Animal {
+String name
+makeSound() void
}Inheritance
Animal <|-- DogComposition
Car *-- EngineAggregation
Library o-- BookAssociation
Teacher --> StudentDependency
Class1 ..> Class2Interface
class Shape {
<<interface>>
+area() float
}Abstract
class Animal {
<<abstract>>
}Gantt Chart
Full guide →Header
gantt
title Project Plan
dateFormat YYYY-MM-DDSection
section DesignTask
Design mockups :a1, 2024-01-01, 7dAfter another
Build UI :after a1, 5dActive task
Development :active, a2, 2024-01-08, 10dDone task
Planning :done, 2024-01-01, 3dCritical task
Deploy :crit, 2024-01-20, 2dMilestone
Launch :milestone, 2024-01-22, 0dState Diagram
Full guide →State
stateDiagram-v2
[*] --> IdleTransition
Idle --> Processing : startEnd state
Done --> [*]Composite state
state Active {
[*] --> Running
Running --> Paused
}Fork / join
state fork <<fork>>
fork --> State1
fork --> State2Choice
state check <<choice>>
check --> Yes
check --> NoNote
note right of Idle : Waiting for inputPie Chart
Full guide →Basic pie
pie title Market Share
"Chrome" : 65
"Safari" : 19
"Firefox" : 4Show data
pie showData
...Mind Map
Full guide →Root
mindmap
root((Topic))Branch
Child 1
GrandchildCloud shape
)Cloud node(Bang shape
))Urgent((Hexagon shape
{{Hexagon}}Git Graph
Full guide →Commit
gitGraph
commit id: "initial"Branch
branch develop
commit id: "feat"Checkout
checkout mainMerge
merge developCherry-pick
cherry-pick id: "abc"Tag
commit id: "release" tag: "v1.0"Timeline
Full guide →Basic
timeline
title History
2020 : Event A
2021 : Event B : Event C
2022 : Event DSection
section Phase 1
2020 : MilestoneQuadrant Chart
Full guide →Setup
quadrantChart
title Priority Matrix
x-axis Low Effort --> High Effort
y-axis Low Impact --> High ImpactData point
Quick wins: [0.2, 0.8]Quadrant labels
quadrant-1 Do First
quadrant-2 Schedule
quadrant-3 Delegate
quadrant-4 EliminateXY Chart
Full guide →Bar chart
xychart-beta
title "Sales"
x-axis [Jan, Feb, Mar]
y-axis "Revenue" 0 --> 100
bar [30, 60, 90]Line chart
line [20, 50, 80]Try These Snippets Live
Open the editor with autocomplete, live preview, and export to PNG, SVG, or PDF.
Open Editor