Mermaid diagram examples

Updated

Every Mermaid chart type in one place: a short, copyable example of each, rendered live with Mermaid 11.16, plus a link to the full page of examples for that type and a table of which chart fits which data. Copy an example, paste it into a mermaid code block, and change the labels and numbers.

Bar chart

Categories on the x-axis, a range on the y-axis, values in a bar list; swap bar for line for a line chart. The config block only sets the bar colour. More on the bar chart examples page: horizontal bars, combined plots, labels and colours.

---
config:
  themeVariables:
    xyChart:
      plotColorPalette: "#4f46e5"
---
xychart-beta
    title "Monthly sign-ups"
    x-axis [Jan, Feb, Mar, Apr, May, Jun]
    y-axis "Sign-ups" 0 --> 500
    bar [120, 180, 240, 310, 390, 460]

Pie chart

One line per slice; Mermaid works out the percentages. The pie chart examples page adds showData, donut charts, legend position and colours.

pie showData
    title Survey responses
    "Yes" : 412
    "No" : 128
    "Not sure" : 60

Gantt chart

Tasks with a start and a duration, grouped in sections; after chains tasks and milestone marks a date. The Gantt chart examples page covers dependencies, excluded weekends, axis formats and the today marker.

gantt
    title Website relaunch
    dateFormat YYYY-MM-DD
    section Design
      Wireframes     :done, des1, 2026-01-05, 10d
      Visual design  :active, des2, after des1, 14d
    section Build
      Front end      :dev1, after des2, 21d
      Content        :dev2, after des2, 14d
    section Launch
      Go live        :milestone, m1, after dev1, 0d

Timeline

Periods and the events in them, in order, with no durations. The timeline examples page adds sections, multiple events per period and styling.

timeline
    title Product history
    2023 : Prototype
    2024 : Public beta : First paying customer
    2025 : Version 1.0
    2026 : Mobile app

Mindmap

Indentation is the whole grammar: each deeper level branches from the line above. Node shapes and markdown text are on the mindmap examples page.

mindmap
  root((Launch plan))
    Marketing
      Blog post
      Newsletter
    Product
      Release notes
      Docs update
    Support
      FAQ refresh

Git graph

Commits, branches and merges as a diagram, written as the Git commands you would type. Commit types, tags, cherry-picks and orientation are on the git graph examples page.

gitGraph
    commit id: "init"
    branch feature
    checkout feature
    commit id: "add export"
    commit id: "fix tests"
    checkout main
    merge feature
    commit id: "release" tag: "v1.0"

Quadrant chart

Points placed by two judgements, each between 0 and 1, in four labelled quadrants. Point styling, classes and theme options are on the quadrant chart examples page.

quadrantChart
    title Effort and impact
    x-axis Low effort --> High effort
    y-axis Low impact --> High impact
    quadrant-1 Big bets
    quadrant-2 Quick wins
    quadrant-3 Fill ins
    quadrant-4 Time sinks
    Dark mode: [0.35, 0.7]
    Search filters: [0.75, 0.85]
    Export to CSV: [0.2, 0.4]
    Rewrite billing: [0.9, 0.3]

Sankey diagram

CSV rows of source, target and value; link widths follow the values. Budgets, funnels, traffic and the configuration options are on the sankey diagram examples page.

sankey-beta

Visitors,Signed up,1200
Visitors,Left,8800
Signed up,Activated,700
Signed up,Churned,500
Activated,Paid,210
Activated,Free tier,490

Which Mermaid chart for which data?

Mermaid has a type for most things a document needs to show. The chart-style types take data or plans; the UML-style types describe software. Pick by the shape of your data, not by the look of the chart. Three types that did not fit above have their own example pages: kanban for work by status, radar chart for items compared across criteria, and user journey for the steps a person takes and how each one feels.

Your dataChartKeywordExamples
Shares of one wholePie chartpiepie chart
Amounts by category or over a few periodsBar or line chartxychart-betabar chart
Tasks with dates, durations and dependenciesGantt chartganttGantt chart
Events in order, no durationsTimelinetimelinetimeline
Ideas branching from one topicMindmapmindmapmindmap
Commits, branches and mergesGit graphgitGraphgit graph
A short list ranked by two judgementsQuadrant chartquadrantChartquadrant chart
Where quantities flow between stagesSankey diagramsankey-betasankey diagram
Work items by status columnKanbankanbankanban
Several items across the same criteriaRadar chartradar-betaradar chart
Steps a person takes and how they feelUser journeyjourneyuser journey
A process with decisionsFlowchartflowchartflowchart
Messages between participants over timeSequence diagramsequenceDiagramsequence diagram
Classes and their relationshipsClass diagramclassDiagramclass diagram
States and the transitions between themState diagramstateDiagram-v2state diagram
Database tables and their relationsEntity relationship diagramerDiagramER diagram

How do you use these examples?

Each copy button on this page copies the example wrapped in a fenced code block tagged mermaid, which is the form GitHub, GitLab, Obsidian, Notion and VS Code recognise. Paste it into a README, an issue, a note or a wiki page and the platform draws the diagram. Then edit the labels and numbers in place; because the diagram is text, the picture follows. The Mermaid in Markdown page shows the embedding on each platform and how to check which Mermaid version a platform runs.

To share a rendered diagram with people who are not in your repository or workspace, paste the Markdown into the Docs MD editor and send the link: the shared page renders every mermaid block with Mermaid 11.16 and prints cleanly, and PDF export draws the diagrams before converting. The architecture diagram guide walks through a typical document with several diagrams.

Which Mermaid version do the examples need?

Every example on docs-md.com is rendered with Mermaid 11.16 and uses syntax taken from Mermaid’s documentation for that version. Most of the types are old enough to work everywhere: pie, Gantt, git graph and user journey predate Mermaid 10, timeline and mindmap are from 9.x, the quadrant chart from 10.2.0, sankey from 10.3.0 and the XY chart from 10.6.0. Two are recent: kanban needs 11.4.0 and the radar chart 11.6.0.

Individual options are often newer than their chart. The pie chart’s donutHole needs 11.16.0, bar chart data labels 11.14.0, and the sankey node options 11.15.0; each example page notes the version next to the option. Where it matters, the examples use the older spellings xychart-beta and sankey-beta, which every version since the chart was introduced accepts, rather than the suffix-free keywords that only work from 11.10.0.

What else can Mermaid draw?

Beyond the types on this page, Mermaid 11.16 documents C4, requirement, block, packet, architecture, treemap and ZenUML diagrams, and several newer experimental types. For a diagram that does not fit any of these, a flowchart is the usual fallback: it has the most shapes and the most control over layout. The What is a Mermaid diagram page explains how the library works and where it renders; Mermaid’s own syntax reference lists every type with its current status.

Can I use these Mermaid examples in GitHub README files?

Yes. GitHub renders fenced mermaid blocks in Markdown files as well as in issues, pull requests, discussions and wikis, and the copy buttons include the fence. GitHub chooses the Mermaid version it runs, so the newer types (kanban, radar) and newer options may not render there yet; its documentation suggests an info block to see the version. The older types on this page render on any version that supports Mermaid.

Which Mermaid chart is best for comparing numbers?

A bar chart, written with the XY chart type. Put the categories on the x-axis and the values in a bar list; use a line list for change over time, or both for actual against target. Use a pie chart only when the numbers are parts of one whole, and a radar chart when you compare a few items across several criteria that share one scale.

Does Mermaid have a bar chart?

Yes, as part of the XY chart type introduced in Mermaid 10.6.0. The keyword is xychart-beta (or xychart from 11.10.0), and a bar [...] statement draws the bars; line [...] draws a line on the same axes, and horizontal after the keyword turns the bars sideways. The bar chart examples page shows vertical and horizontal bars, data labels and colours.

Where are the flowchart and sequence diagram examples?

On chartcraft.dev, which covers the UML-style Mermaid types: flowchart, sequence, class, state and entity relationship diagrams, each with worked examples. Docs MD focuses on the chart-style types that show data and plans, and on using Mermaid inside Markdown. The table above links to both sets so you can pick the right type first.

How do I check which Mermaid version a platform runs?

Render the one-word diagram info in a mermaid code block on that platform; it draws the version number in place of a diagram. GitHub’s documentation recommends this check. Compare the result with the version noted on each example page before using a newer type or option, and prefer xychart-beta and sankey-beta over the suffix-free keywords when the version is old or unknown.

Sources

More Mermaid examples

Timeline · Pie chart · Gantt chart · Mindmap · Git graph · Mermaid in Markdown · Bar chart · Quadrant chart · Sankey diagram · Kanban · Radar chart · User journey · What is Mermaid · what is a mermaid diagram · mermaid in markdown · markdown viewer · markdown to pdf · share architecture diagram