Mermaid Diagram Types
Purpose
This reference helps authors choose a Mermaid diagram type, use the correct declaration, and provide an accessible alternative that preserves the diagram’s meaning.
Mermaid 11.16.0 is this guide’s reference version. Mermaid adds diagram types and sometimes changes beta declarations. Pin the renderer when the project controls it. When a hosting platform controls the renderer, record the observed version and test the required syntax and output on that platform. Review the official documentation and repeat those tests before upgrading or when the host changes its renderer.
This page is not a record of which narrative generators a particular project has implemented. Keep implementation status in tested, machine-readable project data rather than in a general Mermaid reference.
First Decide Whether a Diagram Is Needed
Use a diagram when relationships, sequence, branching, hierarchy, timing, or spatial grouping materially improve understanding. Prefer ordinary HTML when a short paragraph, list, or table communicates the same information more clearly.
Before choosing a diagram type, identify:
- the question the diagram must answer;
- the essential entities, events, values, or states;
- the essential relationships and their direction;
- whether position, area, time, or sequence carries meaning;
- the structured alternative that will preserve that meaning; and
- the renderer control model, versions, and publishing platforms that must render it.
Do not choose a type merely because its visual style is appealing. Choose the smallest structure that accurately represents the information.
Current Version and Type Status
The Mermaid 11.16.0 source contains 31 user-facing syntax guides when the Railroad guide is counted as one type with four grammar declarations. The documentation sidebar currently links 30 of them and has not yet added the Railroad guide.
Do not publish an unqualified claim that Mermaid supports a fixed number of diagram types. The number depends on the Mermaid version, whether external plugins are counted, and whether related declarations are counted separately.
Mermaid 11.16.0 also has several kinds of status:
- Canonical: the declaration without
-betais accepted by the 11.16.0 detector. - Beta required: only the declaration ending in
-betais accepted. - Compatibility alias: both the canonical declaration and the older
-betaform are accepted. - External plugin: the type is documented with Mermaid but must be registered separately.
- Experimental documentation: the syntax page explicitly warns that the
type or syntax may change, even if the declaration does not end in
-beta.
Status is not uniform across the documentation. For example, the 11.16.0 beta
policy accepts canonical sankey, ishikawa, and treemap declarations,
while their syntax pages retain experimental or new-type warnings. Treat an
explicit page warning as a reason to pin the version when possible and test
the target rendering surface carefully.
Verify the Target Rendering Surface
The reference version in this guide identifies the declarations and documentation reviewed while maintaining the guide. It does not guarantee that a publishing platform uses Mermaid 11.16.0 or supports every type listed here.
Treat each rendering surface as a separate target. This includes GitHub.com, each supported GitHub Enterprise Server release, GitHub Pages, local editors, documentation builds, exported SVG or raster images, and PDF conversion. In particular, GitHub Pages does not inherit the Mermaid renderer used by GitHub.com. Its behavior depends on the site’s theme, plug-ins, scripts, and build configuration.
Use the appropriate control model:
- Project-controlled renderer: pin the exact Mermaid version and configuration, validate diagrams in continuous integration, and test before upgrading.
- Platform-managed renderer: use the platform’s documented version probe where available, record the visible result and observation date, and test required capabilities on that exact surface.
- Pre-rendered output: record the tool, version, configuration, and export method used to create the asset. Test both the asset and its embedding context.
A reported version number is useful provenance, but it is not enough by itself. Verify that the target surface:
- recognizes each required declaration and compatibility alias;
- preserves
accTitleandaccDescrin the final accessible output; - preserves the visible structured alternative;
- applies acceptable light, dark, high-contrast, zoom, and reflow behavior;
- handles links and any interactive content safely; and
- preserves accessibility through SVG, raster, and PDF export paths.
Keep project support claims in tested, machine-readable data rather than in this general reference. A support record should identify the surface, renderer control model, configured or observed version, discovery method, observation date, declarations and accessibility features tested, fallback, and owner.
Quick Selection Guide
| If the main question is… | Start with… | Usually provide… |
|---|---|---|
| What happens next, and where does it branch? | Flowchart | Ordered steps or a decision table |
| Who owns each process step? | Swimlane | Steps with owner and handoff columns |
| Who sends what to whom, and in what order? | Sequence or ZenUML | Chronological message table |
| What states exist and what triggers transitions? | State | State definitions and transition table |
| How are software types or data entities related? | Class or entity relationship | Definitions, attributes, keys, and relationship table |
| When do tasks or events occur? | Gantt or timeline | Date, duration, owner, status, and dependency table |
| How does a person experience a process? | User journey | Stage, action, goal, barrier, and outcome table |
| How are components or services connected? | Architecture, C4, block, or flowchart | Component inventory and relationship table |
| How does work move through columns? | Kanban | Task table grouped by status |
| How is a hierarchy organized? | Mindmap, tree view, or treemap | Nested headings or lists; include values for a treemap |
| How do quantities compare or change? | XY chart, pie, radar, quadrant, Sankey, or treemap | Summary plus the underlying data table |
| How are sets related? | Venn | Set membership and intersection table |
| What causes contribute to an outcome? | Ishikawa | Hierarchical cause list |
| How do branches, commits, and merges relate? | Git graph | Chronological branch and merge history |
| How are requirements traced? | Requirement | Requirement and verification matrix |
| How is a network packet divided? | Packet | Field table with bit ranges and meanings |
| How does a strategy map value and evolution? | Wardley | Component coordinates, dependencies, and evolution table |
| Which Cynefin domain contains each item? | Cynefin | Domain definitions, item list, and transition table |
| How does information change in an event-modeled system? | Event modeling | Timeline of triggers, commands, events, and views |
| What grammar paths are valid? | Railroad | The source grammar and a rule-by-rule explanation |
If several types fit, use the one that requires the least visual convention knowledge from the intended audience.
Diagram Type Reference for Mermaid 11.16.0
The declaration is the first non-frontmatter, non-comment content in a Mermaid definition. Declaration spelling and capitalization matter.
Process, Interaction, and Time
| Type | Declaration | 11.16.0 note | Best for | Structured alternative |
|---|---|---|---|---|
| Flowchart | flowchart or graph plus direction |
Canonical | Steps, decisions, dependencies, and networks | Ordered steps, nested lists, or decision table |
| Swimlane | swimlane-beta plus optional direction |
Beta required; added in 11.16.0 | Processes divided by actor, team, system, or phase | Step, owner, input, output, and handoff table |
| Sequence | sequenceDiagram |
Canonical | Time-ordered messages among participants | Numbered message table with from, to, action, and response |
| State | stateDiagram-v2 or stateDiagram |
Canonical | States, events, guards, and transitions | State definitions and source, trigger, destination, outcome table |
| User journey | journey |
Canonical | User stages, activities, actors, and satisfaction scores | Ordered stage, actor, action, score, barrier, and opportunity table |
| Gantt | gantt |
Canonical | Tasks, dates, durations, milestones, and dependencies | Task schedule with dates, duration, owner, status, and dependencies |
| Timeline | timeline |
Canonical | Chronological events and periods | Chronological event list or table with exact dates |
| Kanban | kanban |
Canonical | Work items grouped by workflow stage | Task table grouped by stage, with owner, priority, and status |
| Event modeling | eventmodeling |
Canonical; added in 11.15.0 | Information flow through triggers, commands, events, and views | Time-frame table preserving lanes, entities, data, and relationships |
Structure, Software, and Systems
| Type | Declaration | 11.16.0 note | Best for | Structured alternative |
|---|---|---|---|---|
| Class | classDiagram |
Canonical | Classes, members, inheritance, composition, and association | Class definitions plus member and relationship tables |
| Entity relationship | erDiagram |
Canonical | Entities, attributes, keys, cardinality, and relationships | Entity definitions plus keys, attributes, and relationship table |
| Architecture | architecture; architecture-beta remains accepted |
Compatibility alias | Services, groups, junctions, boundaries, and connections | Component inventory with responsibility, group, interface, and dependency |
| C4 | C4Context, C4Container, C4Component, C4Dynamic, or C4Deployment |
Documentation explicitly calls C4 experimental | C4 system, container, component, dynamic, and deployment views | Elements, boundaries, responsibilities, technologies, and relationships |
| Block | block; block-beta remains accepted |
Compatibility alias | Author-positioned blocks and connectors | Block inventory and directed relationship table |
| Mindmap | mindmap |
Canonical | Concept hierarchies and branches | Properly nested headings or lists |
| TreeView | treeView-beta |
Beta required | Directory-like hierarchical structures | Nested list or tree with annotations |
| ZenUML | zenuml after plugin registration |
External @mermaid-js/mermaid-zenuml plugin; lazy loading and async rendering are experimental |
Nested calls and control flow in sequence diagrams | Chronological message table with nesting and branch conditions |
Data and Analytical Views
| Type | Declaration | 11.16.0 note | Best for | Structured alternative |
|---|---|---|---|---|
| Pie | pie |
Canonical | A small part-to-whole comparison | Data table with category, value, unit, and calculated percentage |
| XY chart | xychart; xychart-beta remains accepted |
Compatibility alias | Bar and line series on categorical or numeric axes | Data table with series, x value, y value, and units |
| Quadrant chart | quadrantChart |
Canonical | Items positioned on two meaningful axes | Item table with exact x and y values and quadrant |
| Radar | radar-beta |
Beta required | Comparing a few entities across the same dimensions | Matrix of entities, dimensions, values, scale, and units |
| Sankey | sankey; sankey-beta remains accepted |
Compatibility alias; syntax page still says experimental | Quantified flows from sources through transformations to targets | Source, target, value, and unit table plus a findings summary |
| Treemap | treemap; treemap-beta remains accepted |
Compatibility alias; syntax page warns that this is a new type | Hierarchical part-to-whole comparison by area | Nested hierarchy and value table with units |
| Venn | venn-beta |
Beta required | Membership and intersections among a small number of sets | Set membership and intersection table |
Domain-Specific Views
| Type | Declaration | 11.16.0 note | Best for | Structured alternative |
|---|---|---|---|---|
| Git graph | gitGraph |
Canonical | Branches, commits, checkouts, cherry-picks, and merges | Chronological branch and commit history |
| Requirement | requirementDiagram |
Canonical | Requirements, elements, risk, verification, and trace relationships | Requirement traceability and verification matrix |
| Packet | packet; packet-beta remains accepted |
Compatibility alias | Bit fields in a network packet or binary structure | Field, start bit, end bit, length, value, and description table |
| Ishikawa | ishikawa; ishikawa-beta remains accepted |
Compatibility alias; syntax page warns that this is a new type | Hierarchical causes contributing to a problem or outcome | Nested cause list grouped by category |
| Wardley | wardley-beta |
Beta required | Components positioned by visibility and evolution | Component, visibility, evolution, dependency, inertia, and note table |
| Cynefin | cynefin-beta |
Beta required; added in 11.16.0 | Items classified into complexity domains and transitions between domains | Domain definitions plus item and transition tables |
| Railroad | railroad-ebnf-beta, railroad-abnf-beta, railroad-peg-beta, or railroad-beta |
Beta required; added in 11.16.0 | EBNF, ABNF, PEG, or Mermaid railroad IR grammar paths | Source grammar and a rule-by-rule description of sequence, choice, and repetition |
Choose Data Charts Carefully
Mermaid can render several chart types, but convenience does not make every chart a good choice.
- Use a pie chart only for a small part-to-whole comparison. A sorted bar chart is often easier to compare.
- Do not use a radar chart when precise comparison is important. A grouped bar chart or data table is usually easier to read.
- Use a quadrant chart only when both axes and the coordinates have defined meaning. Do not turn subjective labels into false precision.
- Use a Sankey diagram only when flow quantity is essential. State the units and provide the source, target, and value data.
- A treemap’s area is difficult to compare precisely. Provide the values and hierarchy outside the graphic.
- Limit Venn diagrams to a small number of sets. Complex set relationships are usually clearer in a membership matrix.
Do not rely on color to distinguish a series, category, status, set, or path. Use direct labels, patterns where supported, line styles, markers, position, and a data table. Verify text contrast and the contrast of meaningful graphical objects in every supported theme.
Add Mermaid Accessibility Metadata
Mermaid documents accTitle and accDescr for all diagram and chart types.
Use the keywords without comment markers:
flowchart TD
accTitle: Account recovery decision flow
accDescr {
A user submits an email address. If an account is found, the system sends
a recovery link. Otherwise, the system offers additional help.
}
A[Submit email address] --> B{Account found?}
B -->|Yes| C[Send recovery link]
B -->|No| D[Offer additional help]
Mermaid comments begin with %%. These lines are ignored as comments and do
not provide accessibility metadata:
%%accTitle This is ignored
%%accDescr This is also ignored
Use a colon after accTitle and after a single-line accDescr. For a
multi-line description, omit the colon and enclose the description in braces.
accTitle and accDescr improve the generated SVG’s accessible name and
description. They do not turn nodes, edges, bars, slices, or regions into a
navigable semantic structure. Complex diagrams still need visible structured
alternatives.
Match the Alternative to the Type
Sequence example
sequenceDiagram
accTitle: Password reset request sequence
accDescr: The website obtains a reset token and asks the email service to send it.
actor User
participant Site as Website
participant Identity as Identity service
participant Email as Email service
User->>Site: Request password reset
Site->>Identity: Create reset token
Identity-->>Site: Return token
Site->>Email: Send reset link
Email-->>Site: Confirm queued message
Site-->>User: Confirm request
The structured alternative should preserve the message order:
<table>
<caption>Password reset messages</caption>
<thead>
<tr>
<th scope="col">Step</th>
<th scope="col">From</th>
<th scope="col">To</th>
<th scope="col">Message</th>
</tr>
</thead>
<tbody>
<tr><td>1</td><td>User</td><td>Website</td><td>Request password reset</td></tr>
<tr><td>2</td><td>Website</td><td>Identity service</td><td>Create reset token</td></tr>
<tr><td>3</td><td>Identity service</td><td>Website</td><td>Return token</td></tr>
<tr><td>4</td><td>Website</td><td>Email service</td><td>Send reset link</td></tr>
<tr><td>5</td><td>Email service</td><td>Website</td><td>Confirm queued message</td></tr>
<tr><td>6</td><td>Website</td><td>User</td><td>Confirm request</td></tr>
</tbody>
</table>
XY chart example
xychart
accTitle: Completed accessibility reviews by quarter
accDescr: Completed reviews increased from 12 in quarter one to 27 in quarter four. The data table follows.
x-axis [Q1, Q2, Q3, Q4]
y-axis "Completed reviews" 0 --> 30
bar [12, 18, 21, 27]
<table>
<caption>Completed accessibility reviews by quarter</caption>
<thead>
<tr>
<th scope="col">Quarter</th>
<th scope="col">Completed reviews</th>
</tr>
</thead>
<tbody>
<tr><th scope="row">Q1</th><td>12</td></tr>
<tr><th scope="row">Q2</th><td>18</td></tr>
<tr><th scope="row">Q3</th><td>21</td></tr>
<tr><th scope="row">Q4</th><td>27</td></tr>
</tbody>
</table>
Tree example
treeView-beta
accTitle: Documentation repository structure
accDescr: The repository contains source and examples directories plus configuration and readme files.
docs/
source/
introduction.md
examples/
flowchart.md
README.md
Also expose the hierarchy as a nested list or a native file tree component. Do not assume indentation in the Mermaid source will be available to readers of the rendered SVG.
Narrative Generation and Automation
A project may generate a prose or HTML alternative from Mermaid source, but that is a project feature, not a built-in guarantee of each diagram type.
Use a semantic model
Prefer this pipeline:
- validate the exact Mermaid source with the pinned renderer or tested target platform;
- parse the type with version-matched tooling;
- transform the source into a type-specific semantic model;
- generate both the visual diagram and its structured alternative from that model;
- escape untrusted text before inserting it into HTML; and
- compare the source, diagram, and alternative in automated tests.
Do not use a few regular expressions as a general Mermaid parser. Mermaid supports nesting, quoted text, comments, frontmatter, multiple declarations, and type-specific grammar. A line-based expression that works for a simple example can silently omit branches, cardinality, parallel sequences, composite states, or data values.
Mermaid’s internal parser and diagram database APIs are not a stable semantic interchange contract. If a project depends on internal APIs, pin the Mermaid version when controlled and run regression tests before every upgrade or observed host change.
Define support honestly
For each supported type, document and test:
- accepted declarations and aliases;
- source features the generator understands;
- source features it rejects or cannot preserve;
- the semantic elements and relationships in the output;
- malformed-input behavior;
- HTML escaping and URL sanitization;
- synchronization between visual and alternative output; and
- tests using nested, empty, malformed, and adversarial input.
If the generator cannot preserve the diagram’s essential meaning, require an author-written structured alternative. Do not produce confident but incomplete prose.
Store generator coverage in a tested JSON, YAML, or code manifest. Generate any human-readable support table from that source so the documentation cannot drift from the implementation.
Rendering and Publishing Requirements
The same Mermaid source can produce different results across a live browser renderer, a static site plug-in, Mermaid CLI, an editor preview, a raster export, and a PDF conversion.
For every supported publishing path:
- record whether the renderer is project-controlled, platform-managed, or used to create pre-rendered output;
- record the configured or observed Mermaid version, discovery method, configuration, surface, and observation date;
- parse every diagram during continuous integration when the project controls the build, and run representative capability tests on managed platforms;
- inspect the final generated SVG or image;
- verify that title and description relationships survive embedding;
- verify the visible structured alternative remains adjacent or clearly linked;
- test light, dark, high-contrast, zoom, and narrow viewport presentation;
- test keyboard access only where the diagram contains real interaction; and
- test representative output with screen readers.
A static SVG diagram should not receive tabindex="0" merely so it can be
focused. If nodes or links are interactive, implement them as real operable
controls or links with visible focus, meaningful names, and documented keyboard
behavior.
When the project controls Mermaid, pin an exact version rather than loading an
unconstrained major or latest release. Keep Mermaid’s
securityLevel: 'strict' default unless a documented and tested requirement
justifies a different setting. Treat user-authored Mermaid source, labels,
links, configuration, and generated HTML as untrusted input.
Testing Checklist
Source and version
- The renderer control model is documented.
- A project-controlled Mermaid version is pinned exactly.
- A platform-managed version is observed where possible, with the surface, discovery method, and observation date recorded.
- Every declaration is supported by the configured version or tested target platform.
- Beta and external plugin dependencies are documented.
- Every Mermaid block parses in continuous integration when the build is project-controlled; representative diagrams are tested on managed platforms.
- Unsupported syntax fails visibly rather than disappearing silently.
Meaning and alternatives
- The chosen type matches the question the diagram must answer.
accTitleidentifies the diagram concisely.accDescrsummarizes the essential meaning.- Complex information has a visible structured alternative.
- The alternative preserves order, hierarchy, direction, values, units, conditions, and relationships as applicable.
- The visual and alternative are generated or reviewed together.
Visual presentation
- Meaning does not depend on color alone.
- Text and meaningful graphical objects meet applicable contrast requirements.
- Labels remain readable at 200% and 400% zoom.
- The diagram does not cause page-wide horizontal scrolling at narrow widths; a local scroll region or alternate view is provided when needed.
- Light, dark, and forced-color presentation have been checked.
Interaction and output
- Static diagrams are not added to the tab order.
- Interactive elements use native links or controls when possible.
- All interaction works with a keyboard and has visible focus.
- Accessible names and descriptions survive the final embedding method.
- Raster and PDF exports include an equivalent alternative in the surrounding document.
- Representative output has been tested with assistive technologies.
Common Failures
- Publishing a fixed count of Mermaid types without naming the Mermaid version.
- Listing a declaration that the deployed renderer does not recognize.
- Treating a sidebar icon as an authoritative stability classification.
- Assuming ZenUML is included in the Mermaid core bundle.
- Calling C4 stable while its own syntax page says it is experimental.
- Using
%%accTitleor%%accDescr, which comments out the metadata. - Assuming
accDescrreplaces a structured alternative for a complex diagram. - Flattening a graph into prose that loses direction, branches, cardinality, or values.
- Parsing every diagram type with line-based regular expressions.
- Generating raw HTML from unescaped diagram labels.
- Relying on a chart’s visual area, color, or position without exposing exact data.
- Testing only in the Mermaid Live Editor rather than in the final site.
- Assuming GitHub.com, GitHub Enterprise Server, GitHub Pages, editor previews, and exports use the same renderer or configuration.
- Treating a reported version number as proof that the required syntax, accessibility metadata, themes, and export paths work.
- Loading an unpinned Mermaid release when the project controls the renderer.
Definition of Done
A Mermaid diagram is ready to publish when:
- the type is appropriate for the information;
- its declaration parses with the pinned production renderer or tested target platform;
- beta or plugin dependencies are intentional and documented;
- it has a useful
accTitleandaccDescr; - a visible structured alternative preserves its essential meaning;
- color, contrast, zoom, reflow, and theme behavior have been checked;
- any interaction is keyboard operable and exposes useful semantics;
- the final embedded or exported output has been tested; and
- the diagram, its data, and its alternative have a synchronization and review process.
Related Guides
- Mermaid Accessibility Best Practices
- Mermaid Transformation Best Practices
- Charts and Graphs Accessibility Best Practices
- SVG Accessibility Best Practices
- Tables Accessibility Best Practices
- Color Contrast Accessibility Best Practices
- Keyboard Accessibility Best Practices
References
Mermaid
- Diagram syntax and configuration
- Accessibility options
- Mermaid configuration
- Mermaid releases
- Mermaid 11.16.0 release
- ZenUML plugin
GitHub Rendering Surfaces
Accessibility Standards
- WCAG 2.2: Text Alternatives
- WCAG 2.2: Use of Color
- WCAG 2.2: Contrast (Minimum)
- WCAG 2.2: Non-text Contrast
- WCAG 2.2: Reflow
- WAI Images Tutorial: Complex Images
- WAI Tables Tutorial
Mermaid Version Information
This guide uses Mermaid 11.16.0 as its reference version. The reference version identifies the diagram declarations and documentation reviewed while maintaining this guide. It does not claim that every platform uses that version.
The diagram below reports the Mermaid version supplied by the current Markdown hosting platform. It may differ from the version used by GitHub Enterprise Server, GitHub Pages, local builds, editors, exported diagrams, or other rendering services.
info
The result is dynamic diagnostic output, not durable documentation. When version provenance matters, record the visible value together with the surface, discovery method, and observation date in plain text or machine-readable project data.
This document is available under the repository’s MIT License.