Chalkline / Guides / Mermaid flowchart cheat sheet

Mermaid flowchart cheat sheet

Mermaid lets you write a flowchart as text and have it drawn for you. Here is all the flowchart syntax you need on one page, and a free editor that turns it into a hand drawn or clean diagram.

Updated 7 November 2026 · 2 minute read

The first line: direction

Every flowchart starts with flowchart (or the older graph) and a direction:

CodeDirection
flowchart TD or TBTop to bottom
flowchart LRLeft to right
flowchart BTBottom to top
flowchart RLRight to left

Node shapes

A node is an id followed by its text inside brackets. The bracket style picks the shape.

a[Rectangle]          a process step
b([Stadium])          start or end
c((Circle))           event or connector
d{Diamond}            decision
e{{Hexagon}}          preparation
f[(Cylinder)]         database
g(Rounded)            rounded step
h>Flag]               note or flag

If you use an id again without brackets, Mermaid reuses the same node, so define the text once.

a --> b               arrow
a --- b               line without an arrow
a -.-> b              dotted arrow
a ==> b               thick arrow
a -->|yes| b          arrow with a label
a -- yes --> b        another way to label
a --> b --> c         chain several in one line

A complete example

A pull request review written in MermaidA pull request review written in MermaidPull request openedTests pass?Fix the codeReview approved?Merge to mainDeployednoyeschanges askedyes
A pull request review written in MermaidOpen this example in Chalkline →

The text behind that picture:

flowchart TD
  pr([Pull request opened]) --> ci{Tests pass?}
  ci -->|no| fix[Fix the code] --> ci
  ci -->|yes| rv{Review approved?}
  rv -->|changes asked| fix
  rv -->|yes| merge[Merge to main] --> deploy([Deployed])

Common mistakes

ProblemCauseFix
Error near a word like endSome words are reservedUse finish or done as the id
Text with brackets breaksBrackets end the label earlyPut the label in quotes: a["Step (draft)"]
Two boxes with the same textDifferent idsReuse the same id
Very wide chartLong left to right chainsSwitch to TD or split the chart

Editing Mermaid visually

Writing text is fast, but moving a box by hand is often faster than rewriting it. In Chalkline, open Diagram as text, paste your Mermaid and press Apply. You can then drag shapes, recolour them, switch between sketch and clean, and copy the Mermaid back out. Shapes you moved keep their place when you edit the text again.

Paste your Mermaid into ChalklineFree, offline, and the layout is done for you
Open the example

Beyond flowcharts

Chalkline also reads Mermaid sequence, class, ER, state, Gantt, timeline and mind map diagrams, plus D2 and PlantUML activity diagrams. See the sequence diagram tutorial and UML class diagram examples.