Mermaid diagram syntax

Mermaid diagrams are architecture assets. Use them when a relationship, sequence, lifecycle, or map is clearer as structured text than as prose or a static image.

Prefer the smallest diagram type that explains the idea. Keep diagrams local, reviewable, and close to the page that depends on them.

Load Mermaid on the page#

Mermaid JavaScript is not loaded globally. Any page that contains a Mermaid fence or the mermaid shortcode must opt in through its front matter:

mermaid: true

layouts/_default/baseof.html reads this page parameter and imports Mermaid only for that page. Without it, the diagram source remains in the rendered HTML but is not converted to an SVG diagram.

Syntax inventory#

The source of truth for syntax is Mermaid’s Diagram Syntax documentation.

Diagram typeUse whenMermaid syntax
FlowchartShowing decisions, steps, branching, or system movementFlowchart
Swimlanes diagramShowing work split across actors, systems, or responsibilitiesSwimlanes Diagram
Sequence diagramShowing messages or calls over timeSequence Diagram
Class diagramShowing object models, type relationships, or interface structureClass Diagram
State diagramShowing lifecycle states and transitionsState Diagram
Entity relationship diagramShowing data entities and relationshipsEntity Relationship Diagram
User journeyShowing user stages, tasks, and satisfactionUser Journey
GanttShowing schedules, phases, or delivery windowsGantt
Pie chartShowing simple part-to-whole comparisonsPie Chart
Quadrant chartPlotting items across two dimensionsQuadrant Chart
Requirement diagramShowing requirements and relationships between themRequirement Diagram
GitGraph diagramShowing Git branches, commits, merges, and release movementGitGraph (Git) Diagram
C4 diagramShowing system context, containers, components, and deployment viewsC4 Diagram
MindmapShowing hierarchical ideas or notesMindmaps
TimelineShowing events in chronological orderTimeline
ZenUMLShowing sequence-style interaction with ZenUML syntaxZenUML
SankeyShowing flows and quantities between stagesSankey
XY chartShowing simple charted values on x and y axesXY Chart
Block diagramShowing labelled blocks and spatial relationshipsBlock Diagram
PacketShowing packet or frame structurePacket
KanbanShowing cards grouped by workflow statusKanban
ArchitectureShowing architecture services, groups, and edgesArchitecture
RadarShowing maturity, capability, or assessment scoresRadar
Event modellingShowing events, commands, views, and user interactions over timeEvent Modelling
TreemapShowing hierarchical quantities by areaTreemap
VennShowing overlaps between setsVenn
IshikawaShowing cause-and-effect analysisIshikawa
WardleyShowing value chains and evolutionWardley
CynefinSorting situations by decision-making domainCynefin
TreeViewShowing file trees, hierarchies, or nested structuresTreeView
Other examplesChecking syntax patterns that do not fit one family cleanlyOther Examples

Use rules#

  • Use Mermaid when the diagram benefits from version control, diffs, and local review.
  • Use a static image when visual fidelity matters more than source readability.
  • Keep labels short. If the label needs a paragraph, the diagram is carrying too much meaning.
  • Prefer one diagram per concept. Split large diagrams before they become maps of everything.
  • Keep diagram source in the Markdown page unless the same source is reused by multiple pages.