mermaid 11.15.0
Overview
Mermaid generates diagrams from plain-text descriptions. Write diagram syntax inside a markdown code block fenced with ```mermaid.
All supported diagram types: flowcharts/graphs, sequence diagrams, state diagrams (v2), class diagrams, Gantt charts, entity-relationship diagrams, pie charts, git commit graphs, user journey diagrams, mindmaps, timelines, XY charts (bar/line), radar charts, quadrant charts, Sankey flow diagrams, block diagrams, cloud architecture diagrams, C4 model diagrams (context/container/component/dynamic/deployment), network packet diagrams, treemaps, Venn diagrams, Wardley strategy maps, Ishikawa fishbone diagrams, Kanban boards, and SysML requirement diagrams.
This skill provides syntax reference for every diagram type and a validation pipeline using the official Mermaid parser.
Usage
Validate a diagram
Validate mermaid code from stdin:
echo 'flowchart LR
A-->B' | mermaid.sh validate -
Validate a markdown file (checks all ```mermaid blocks):
mermaid.sh validate ./docs/diagram.md
Validate a directory recursively:
mermaid.sh validate ./docs/ --quiet
JSON output:
mermaid.sh validate --json ./diagram.md
Convert to SVG/PNG
Use mermaid.sh render to convert .mmd or .md files to SVG or PNG:
# Single file to SVG (default output format)
mermaid.sh render -i diagram.mmd
# Explicit output path
mermaid.sh render -i diagram.mmd -o diagram.svg
mermaid.sh render -i diagram.mmd -o diagram.png
# With theme
mermaid.sh render -i diagram.mmd -t dark -o diagram.svg
# From a markdown file (extracts mermaid blocks)
mermaid.sh render -i notes.md -o output/
The script reads .mmd files (raw mermaid) or .md files (extracts fenced mermaid blocks). Output format is inferred from the -o extension (default: .svg). Run mermaid.sh render --help for all options.
Diagram types at a glance
| Keyword |
Diagram Type |
flowchart / graph |
Flowcharts and graphs |
sequenceDiagram |
Sequence diagrams |
stateDiagram-v2 / stateDiagram |
State diagrams |
classDiagram |
Class (UML) diagrams |
gantt |
Gantt charts |
erDiagram |
Entity-relationship diagrams |
pie |
Pie charts |
gitGraph |
Git commit graphs |
journey |
User journey diagrams |
mindmap |
Mind maps |
timeline |
Timeline diagrams |
xychart |
XY charts (bar/line) |
radar-beta |
Radar/spider charts |
quadrantChart |
Quadrant charts |
sankey |
Sankey flow diagrams |
block |
Block diagrams |
architecture-beta |
Cloud architecture |
C4Context / C4Container / etc. |
C4 model diagrams |
packet |
Network packet diagrams |
treemap-beta |
Treemap diagrams |
venn-beta |
Venn diagrams |
wardley-beta |
Wardley maps |
ishikawa-beta |
Fishbone/Ishikawa |
kanban |
Kanban boards |
requirementDiagram |
Requirements (SysML) |
Gotchas
- Always validate after generating — run
mermaid.sh validate - with the diagram piped to stdin, or mermaid.sh validate <file> for files. Do this every time you generate a mermaid diagram, whether it's inline in a markdown block or written to .md or .mmd file. Fix any parser errors before presenting the diagram.
- The word
end breaks flowcharts — if a node label contains lowercase "end", capitalize it ("End") or wrap in quotes. Same applies to sequence diagrams: use parentheses, brackets, or quotes around the word.
- Leading
o or x in flowchart nodes — A---oB creates a circle edge, not a node named "oB". Add a space or capitalize: A--- Ops.
- **Every example must start with
```mermaid** — the validator extracts blocks matching this fence. Do not use ```mermaid-example or other variants in final output.
- Beta diagrams use
-beta suffix — radar-beta, architecture-beta, treemap-beta, venn-beta, wardley-beta, ishikawa-beta. The keyword must include the suffix.
stateDiagram-v2 vs stateDiagram — prefer stateDiagram-v2 (newer renderer with composite states, concurrency). The older stateDiagram still works but lacks features.
- YAML frontmatter config — diagram-level configuration goes between
--- fences before the diagram keyword. Use config: for per-diagram settings and title: for display titles.
- Validation uses the real parser — run
mermaid.sh validate - with diagram code piped to stdin. The script catches syntax errors the live editor would catch. Fix errors iteratively based on parser feedback.
References
Each reference file covers one diagram type with syntax rules and validated examples:
- 01-flowchart.md — Flowcharts, graphs, node shapes, edges, subgraphs, styling
- 02-sequenceDiagram.md — Participants, messages, activations, loops, alt/opt
- 03-stateDiagram.md — States, transitions, composite states, forks, concurrency
- 04-classDiagram.md — Classes, inheritance, composition, namespaces, generics
- 05-gantt.md — Tasks, sections, milestones, dependencies, date formats
- 06-erDiagram.md — Entities, relationships, cardinality, attributes, keys
- 07-pie.md — Pie charts with slices and data labels
- 08-gitGraph.md — Commits, branches, merges, cherry-picks, orientations
- 09-userJourney.md — User journeys with sections, tasks, scores
- 10-mindmap.md — Hierarchical mindmaps, shapes, icons, markdown strings
- 11-timeline.md — Timelines with sections, events, directions
- 12-xyChart.md — Bar and line charts on x/y axes
- 13-radar.md — Radar/spider charts with multiple curves
- 14-quadrantChart.md — Four-quadrant scatter plots
- 15-sankey.md — Flow/sankey diagrams showing value transfers
- 16-block.md — Block diagrams with full layout control
- 17-architecture.md — Cloud architecture with groups and services
- 18-c4.md — C4 model (context, container, component)
- 19-packet.md — Network packet structure diagrams
- 20-treemap.md — Hierarchical treemap visualizations
- 21-venn.md — Set relationships with overlapping circles
- 22-wardley.md — Wardley strategy maps
- 23-ishikawa.md — Cause-and-effect fishbone diagrams
- 24-kanban.md — Kanban workflow boards
- 25-requirementDiagram.md — SysML requirement diagrams
1---2name: mermaid-11-15-0-23description: Mermaid diagram syntax reference and validation. Use when writing, debugging, or converting Mermaid diagrams: flowchart, sequenceDiagram, stateDiagram, classDiagram, gantt, erDiagram, pie, gitgraph, journey, mindmap, timeline, xychart, radar-beta, quadrantChart, sankey, block, architecture-beta, c4, packet, treemap-beta, venn-beta, wardley-beta, ishikawa-beta, kanban, requirementDiagram.4---56# mermaid 11.15.078## Overview910Mermaid generates diagrams from plain-text descriptions. Write diagram syntax inside a markdown code block fenced with ` ```mermaid `.1112All supported diagram types: flowcharts/graphs, sequence diagrams, state diagrams (v2), class diagrams, Gantt charts, entity-relationship diagrams, pie charts, git commit graphs, user journey diagrams, mindmaps, timelines, XY charts (bar/line), radar charts, quadrant charts, Sankey flow diagrams, block diagrams, cloud architecture diagrams, C4 model diagrams (context/container/component/dynamic/deployment), network packet diagrams, treemaps, Venn diagrams, Wardley strategy maps, Ishikawa fishbone diagrams, Kanban boards, and SysML requirement diagrams.1314This skill provides syntax reference for every diagram type and a validation pipeline using the official Mermaid parser.1516## Usage1718### Validate a diagram1920Validate mermaid code from stdin:2122```bash23echo 'flowchart LR24 A-->B' | mermaid.sh validate -25```2627Validate a markdown file (checks all ` ```mermaid ` blocks):2829```bash30mermaid.sh validate ./docs/diagram.md31```3233Validate a directory recursively:3435```bash36mermaid.sh validate ./docs/ --quiet37```3839JSON output:4041```bash42mermaid.sh validate --json ./diagram.md43```4445### Convert to SVG/PNG4647Use `mermaid.sh render` to convert `.mmd` or `.md` files to SVG or PNG:4849```bash50# Single file to SVG (default output format)51mermaid.sh render -i diagram.mmd5253# Explicit output path54mermaid.sh render -i diagram.mmd -o diagram.svg55mermaid.sh render -i diagram.mmd -o diagram.png5657# With theme58mermaid.sh render -i diagram.mmd -t dark -o diagram.svg5960# From a markdown file (extracts mermaid blocks)61mermaid.sh render -i notes.md -o output/62```6364The script reads `.mmd` files (raw mermaid) or `.md` files (extracts fenced mermaid blocks). Output format is inferred from the `-o` extension (default: `.svg`). Run `mermaid.sh render --help` for all options.6566### Diagram types at a glance6768| Keyword | Diagram Type |69|---|---|70| `flowchart` / `graph` | Flowcharts and graphs |71| `sequenceDiagram` | Sequence diagrams |72| `stateDiagram-v2` / `stateDiagram` | State diagrams |73| `classDiagram` | Class (UML) diagrams |74| `gantt` | Gantt charts |75| `erDiagram` | Entity-relationship diagrams |76| `pie` | Pie charts |77| `gitGraph` | Git commit graphs |78| `journey` | User journey diagrams |79| `mindmap` | Mind maps |80| `timeline` | Timeline diagrams |81| `xychart` | XY charts (bar/line) |82| `radar-beta` | Radar/spider charts |83| `quadrantChart` | Quadrant charts |84| `sankey` | Sankey flow diagrams |85| `block` | Block diagrams |86| `architecture-beta` | Cloud architecture |87| `C4Context` / `C4Container` / etc. | C4 model diagrams |88| `packet` | Network packet diagrams |89| `treemap-beta` | Treemap diagrams |90| `venn-beta` | Venn diagrams |91| `wardley-beta` | Wardley maps |92| `ishikawa-beta` | Fishbone/Ishikawa |93| `kanban` | Kanban boards |94| `requirementDiagram` | Requirements (SysML) |9596## Gotchas9798- **Always validate after generating** — run `mermaid.sh validate -` with the diagram piped to stdin, or `mermaid.sh validate <file>` for files. Do this every time you generate a mermaid diagram, whether it's inline in a markdown block or written to `.md` or `.mmd` file. Fix any parser errors before presenting the diagram.99- **The word `end` breaks flowcharts** — if a node label contains lowercase "end", capitalize it ("End") or wrap in quotes. Same applies to sequence diagrams: use parentheses, brackets, or quotes around the word.100- **Leading `o` or `x` in flowchart nodes** — `A---oB` creates a circle edge, not a node named "oB". Add a space or capitalize: `A--- Ops`.101- **Every example must start with ` ```mermaid`** — the validator extracts blocks matching this fence. Do not use ` ```mermaid-example` or other variants in final output.102- **Beta diagrams use `-beta` suffix** — `radar-beta`, `architecture-beta`, `treemap-beta`, `venn-beta`, `wardley-beta`, `ishikawa-beta`. The keyword must include the suffix.103- **`stateDiagram-v2` vs `stateDiagram`** — prefer `stateDiagram-v2` (newer renderer with composite states, concurrency). The older `stateDiagram` still works but lacks features.104- **YAML frontmatter config** — diagram-level configuration goes between `---` fences before the diagram keyword. Use `config:` for per-diagram settings and `title:` for display titles.105- **Validation uses the real parser** — run `mermaid.sh validate -` with diagram code piped to stdin. The script catches syntax errors the live editor would catch. Fix errors iteratively based on parser feedback.106107## References108109Each reference file covers one diagram type with syntax rules and validated examples:110111- [01-flowchart.md](references/01-flowchart.md) — Flowcharts, graphs, node shapes, edges, subgraphs, styling112- [02-sequenceDiagram.md](references/02-sequenceDiagram.md) — Participants, messages, activations, loops, alt/opt113- [03-stateDiagram.md](references/03-stateDiagram.md) — States, transitions, composite states, forks, concurrency114- [04-classDiagram.md](references/04-classDiagram.md) — Classes, inheritance, composition, namespaces, generics115- [05-gantt.md](references/05-gantt.md) — Tasks, sections, milestones, dependencies, date formats116- [06-erDiagram.md](references/06-erDiagram.md) — Entities, relationships, cardinality, attributes, keys117- [07-pie.md](references/07-pie.md) — Pie charts with slices and data labels118- [08-gitGraph.md](references/08-gitGraph.md) — Commits, branches, merges, cherry-picks, orientations119- [09-userJourney.md](references/09-userJourney.md) — User journeys with sections, tasks, scores120- [10-mindmap.md](references/10-mindmap.md) — Hierarchical mindmaps, shapes, icons, markdown strings121- [11-timeline.md](references/11-timeline.md) — Timelines with sections, events, directions122- [12-xyChart.md](references/12-xyChart.md) — Bar and line charts on x/y axes123- [13-radar.md](references/13-radar.md) — Radar/spider charts with multiple curves124- [14-quadrantChart.md](references/14-quadrantChart.md) — Four-quadrant scatter plots125- [15-sankey.md](references/15-sankey.md) — Flow/sankey diagrams showing value transfers126- [16-block.md](references/16-block.md) — Block diagrams with full layout control127- [17-architecture.md](references/17-architecture.md) — Cloud architecture with groups and services128- [18-c4.md](references/18-c4.md) — C4 model (context, container, component)129- [19-packet.md](references/19-packet.md) — Network packet structure diagrams130- [20-treemap.md](references/20-treemap.md) — Hierarchical treemap visualizations131- [21-venn.md](references/21-venn.md) — Set relationships with overlapping circles132- [22-wardley.md](references/22-wardley.md) — Wardley strategy maps133- [23-ishikawa.md](references/23-ishikawa.md) — Cause-and-effect fishbone diagrams134- [24-kanban.md](references/24-kanban.md) — Kanban workflow boards135- [25-requirementDiagram.md](references/25-requirementDiagram.md) — SysML requirement diagrams