Tools
Mermaid Cheat Sheet — Diagram Syntax Reference
Mermaid draws diagrams from text in GitHub, GitLab, Notion, and most docs tools. This sheet covers the syntax for the diagram types you will use most.
Put it into practice with the matching tool.
Write a Mermaid diagram →Advertisement
Flowchart
flowchart TDTop-down flowchart (LR, RL, BT for other directions)A[Box] B(Rounded) C{Decision}Node shapesD([Stadium]) E[(Database)] F((Circle))More node shapesA --> BArrowA -- yes --> B / A -->|yes| BArrow with a labelA -.-> B / A ==> BDotted / thick arrowA --- BLine without an arrowheadsubgraph Name ... endGroup nodes in a boxclassDef hot fill:#f96; class A hotDefine and apply a style classSequence diagram
sequenceDiagramStart a sequence diagramparticipant A as BrowserDeclare a participant with an aliasA->>B: RequestSolid arrow messageB-->>A: ResponseDashed reply arrowactivate B / deactivate BShow an activation barNote over A,B: textNote spanning participantsalt ok ... else error ... endAlternative paths (also opt, loop, par)ER diagram
erDiagramStart an entity-relationship diagramUSER ||--o{ ORDER : placesOne user places zero or more orders|| |o }o }|Exactly one / zero or one / zero or more / one or moreUSER { int id PK string email }Entity attributes with keysClass and state diagrams
classDiagramStart a class diagramAnimal <|-- DogInheritanceclass Dog { +bark() void }Class with a methodstateDiagram-v2Start a state diagram[*] --> IdleInitial stateIdle --> Busy : startTransition with a labelGantt and pie
gantt
dateFormat YYYY-MM-DDStart a Gantt chartsection BuildGroup tasksDesign :a1, 2026-11-01, 5dTask with an ID, start date, and durationCode :after a1, 10dTask that starts after anotherpie title Traffic
"Search" : 60Pie chart with labelled valuesGeneral
%% commentComment line```mermaidFence that renders on GitHub and GitLabA["Text with (brackets)"]Quote labels that contain special characters