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]
A request is checked before processing. The Yes branch continues, while the No branch explains the error. Returning arrows should represent a real retry or revision path rather than simply filling space.

How to use this tool

  1. Start with the example in the editor and identify the elements that answer your question.
  2. Replace the sample labels and values, previewing after each structural change.
  3. Review the diagram at its intended reading size, then keep the source and export the format your document accepts.

Syntax and interpretation

ConceptHow to apply it
DirectionLR reads left to right; TD reads top to bottom. Choose around the document width and the length of the path.
NodesUse stable short IDs in source and descriptive labels for readers. Reusing an ID refers to the same node.
BranchesLabel 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.