Diagrams / Mermaid Flowchart: Syntax & Examples
Mermaid Flowchart: Syntax & Examples
Learn Mermaid flowchart syntax with nodes, arrows and labeled decisions. Edit a request-processing example and review branches before exporting.
When to use Flowchart
Create a Mermaid flowchart for a process, decision path, or simple dependency chain. Name the starting point and the outcome before adding branches. A useful flowchart lets a reader follow one route without guessing what an unlabeled decision means.
Read the Flowchart example
Diagram source
flowchart LR
A[Receive request] --> B{Valid?}
B -->|Yes| C[Process request]
B -->|No| D[Explain error]How to use this tool
- Start with the example in the editor and identify the elements that answer your question.
- Replace the sample labels and values, previewing after each structural change.
- Review the diagram at its intended reading size, then keep the source and export the format your document accepts.
Syntax and interpretation
| Concept | How to apply it |
|---|---|
| Direction | LR reads left to right; TD reads top to bottom. Choose around the document width and the length of the path. |
| Nodes | Use stable short IDs in source and descriptive labels for readers. Reusing an ID refers to the same node. |
| Branches | Label decision edges with distinct outcomes. Include error paths when they change what a reader should do. |
Common questions
Why does editing a label move other nodes?
Automatic layout places the graph again when content changes. Longer labels alter node sizes. Export an image for a fixed presentation and keep source for future edits.