Mermaid syntax reference
Worked syntax pages for the twenty Mermaid diagram types makesPDF renders — flowcharts and sequence diagrams, class and state diagrams, ER, gantt, pie, gitgraph, xychart, timeline, quadrant, sankey, treemap, mindmap, journey, radar, requirement, C4, kanban and block. Every example is drawn by the same renderer that produces the PDF. Copy one, render it, ship it.
Diagram types
Mermaid flowchart syntax: nodes, edges and subgraphs with examples
Mermaid flowchart syntax with rendered examples: directions, node shapes, edge styles and labels, subgraphs, and a flow you can render to PDF.
Mermaid sequence diagram syntax: participants, messages and notes with examples
Mermaid sequence diagram syntax with rendered examples: participants and aliases, message arrows, notes, actors, and numbered message flows.
Mermaid gantt chart syntax: sections, tasks and milestones with examples
Mermaid gantt chart syntax with rendered examples: sections, task durations, after dependencies, milestones and done/active/crit styling.
Mermaid pie chart syntax: slices, titles and percentages with examples
Mermaid pie chart syntax with rendered examples: labelled slices, proportional values, chart titles, and the showData option that puts values in the legend.
Mermaid xychart-beta syntax: bar and line charts with examples
Mermaid xychart-beta syntax with rendered examples: titles, axis labels and ranges, bar and line series, and multiple series on one chart.
Mermaid class diagram syntax: classes, members and relationships with examples
Mermaid classDiagram syntax with rendered examples: class bodies, visibility markers, annotations, inheritance, composition and dependency arrows.
Mermaid state diagram syntax: states, transitions and choices with examples
Mermaid stateDiagram-v2 syntax with rendered examples: start and end markers, labelled transitions, direction, fork and join bars, and choice diamonds.
Mermaid ER diagram syntax: entities, attributes and cardinality with examples
Mermaid erDiagram syntax with rendered examples: entity blocks, typed attributes with keys, and crow's-foot cardinality from one-to-one to many-to-many.
Mermaid gitGraph syntax: commits, branches and merges with examples
Mermaid gitGraph syntax with rendered examples: commits with ids and tags, branching and checkout, merges, and commit types for release history.
Mermaid timeline syntax: periods, events and sections with examples
Mermaid timeline syntax with rendered examples: periods on a lane, several events per period, titled charts and section bands grouping the chronology.
Mermaid quadrant chart syntax: axes, quadrants and points with examples
Mermaid quadrantChart syntax with rendered examples: titled axes, four labelled quadrants and points placed by x/y values from 0 to 1.
Mermaid sankey diagram syntax: flows, nodes and values with examples
Mermaid sankey-beta syntax with rendered examples: CSV source,target,value rows, multi-stage flows, quoted node names and weighted ribbons.
Mermaid treemap syntax: nested rectangles and values with examples
Mermaid treemap-beta syntax with rendered examples: indentation-built hierarchy, values that size each cell, nested sections and squarified layout.
Mermaid mindmap syntax: hierarchy, node shapes and branches with examples
Mermaid mindmap syntax with rendered examples: indentation-built branches, root and node shapes, line breaks in labels and multi-level topics.
Mermaid journey syntax: user journey maps, scores and actors with examples
Mermaid journey syntax with rendered examples: tasks in order, satisfaction scores from 1 to 5, sections that group a stage, and named actors.
Mermaid radar chart syntax: axes, curves and scale with examples
Mermaid radar-beta syntax with rendered examples: shared axes with labels, multiple curves, key-value values, the scale range and the graticule.
Mermaid requirement diagram syntax: requirements, elements and relations with examples
Mermaid requirementDiagram syntax with rendered examples: typed requirement blocks and their fields, elements, and the seven relation types.
Mermaid C4 diagram syntax: context, containers and relationships with examples
Mermaid C4Context and C4Container syntax with rendered examples: people, systems, containers, boundaries and labelled relationships.
Mermaid kanban syntax: columns, cards and metadata with examples
Mermaid kanban syntax with rendered examples: columns, cards with and without ids, assignees and ticket references, and wrapped card labels.
Mermaid block diagram syntax: columns, spans and sub-grids with examples
Mermaid block-beta syntax with rendered examples: column counts, column spans, space gaps, nested sub-grids, node shapes and labelled edges.
Every page shows the Mermaid source next to the rendered diagram — render any of them straight to PDF on the Markdown tool, or read how diagram blocks work in the Markdown documentation.