Look up Mermaid syntax for flowcharts, sequence diagrams, ER models and more. Use code patterns and editable examples to build your next diagram.
Find a diagram type, compare code with its preview, then open a working example in the editor. Related templates provide complete scenarios.
Syntax essentials
Use stable node IDs and separate display labels. Connect nodes by ID; changing a label should not create a different node.
Put labels containing spaces or punctuation inside double quotes. Use the entity #quot; for a quotation mark within a label, and check the preview.
In flowcharts, use LR for left-to-right or TB for top-to-bottom. Label an arrow with |label|, and put a comment on its own line starting with %%.
Each diagram type has its own grammar. These examples use Pele 1.6.0; some Mermaid features and styling directives may differ. Check the preview before exporting.
Architecture Diagrams
Basic example
architecture-beta
group app(cloud)[Pele Editor]
service browser(internet)[Browser] in app
service editor(server)[Editor UI] in app
service renderer(server)[Mermaid Renderer] in app
service file(disk)[PNG File]
browser:R --> L:editor
editor:R --> L:renderer
renderer:B --> T:file
At a relationship endpoint, || means exactly one, o{ means zero or more, and |{ means one or more. PK, FK and UK identify primary, foreign and unique keys.
erDiagram
CUSTOMER ||--o{ ORDER : places
ORDER ||--|{ LINE_ITEM : contains
CUSTOMER {
int id PK
string email UK
}
ORDER {
int id PK
int customer_id FK
}
LINE_ITEM {
int id PK
int order_id FK
}
graph TD
A[User opens Pele Editor] --> B[Write Mermaid code]
B --> C{Preview looks right?}
C -- Yes --> D[Export PNG]
C -- No --> E[Edit diagram]
E --> B
Use square brackets for rectangles, braces for decisions, parentheses for rounded nodes, and square brackets around parentheses for database cylinders. Solid and dotted arrows can carry labels.
flowchart LR
%% Stable IDs connect nodes; quoted labels hold display text
A["Request (new)"] --> B{Valid?}
B -->|Yes| C([Accepted])
B -.->|No| D["Try again"]
C --> E[(Database)]
Give tasks IDs and use after followed by an ID to express dependencies. A milestone has zero duration; done, active and crit mark task status. Dates here are illustrative.
gantt
title Release plan
dateFormat YYYY-MM-DD
section Prepare
Design :done, design, 2026-10-19, 2d
Build :active, build, after design, 3d
section Release
Test :crit, test, after build, 2d
Launch :milestone, launch, after test, 0d
journey
title Pele Editor User Journey
section Create
Open editor: 5: User
Paste Mermaid code: 4: User
section Review
Check live preview: 5: User
Fix syntax: 3: User
section Share
Export PNG: 5: User
Add to docs: 5: User
quadrantChart
title Diagram Content Priority
x-axis Low effort --> High effort
y-axis Low SEO value --> High SEO value
quadrant-1 Plan
quadrant-2 Invest
quadrant-3 Skip
quadrant-4 Automate
Alt text: [0.2, 0.9]
PNG preview: [0.4, 0.8]
Code sample: [0.3, 0.95]
Long intro: [0.8, 0.5]
Use alt / else / end for alternatives and loop / end for repetition. Declare participants with aliases, then use their IDs in messages.
sequenceDiagram
participant U as User
participant A as API
U->>A: Submit request
alt Valid session
loop Each item
A->>A: Validate item
end
A-->>U: Success
else Expired session
A-->>U: Sign in again
end
Define axes first, then give each curve one value per axis in the same order. Use the same minimum and maximum for a fair comparison; values are illustrative.
Basic example
radar-beta
axis speed["Speed"], cost["Cost"], reliability["Reliability"]
curve a["Option A"]{4, 3, 5}
curve b["Option B"]{3, 5, 3}
max 5
min 0