Mermaid Pie Chart

Pie charts in Markdown from a few lines of text

A Mermaid pie chart is the quickest chart you can put in a Markdown file: one line per slice, a label and a number. No spreadsheet, no image export — it renders in GitHub, GitLab, Obsidian and MDViewer.

Basic Pie Chart

Start with pie, add an optional title, then one line per slice: a quoted label, a colon and a positive number:

Mermaid ```mermaid pie title Where visitors come from "Search" : 58 "Direct" : 27 "AI assistants" : 9 "Social" : 6 ```
Mermaid pie chart of visitor sources: search, direct, AI assistants, social

You do not need percentages — Mermaid adds up the values and works out each slice’s share.

Show the Values

Add showData after pie to print each value next to its label in the legend. Values can have decimals:

Mermaid ```mermaid pie showData title Browser share "Chrome" : 65.2 "Safari" : 18.6 "Edge" : 5.3 "Other" : 10.9 ```
Mermaid pie chart with showData: browser share with decimal values

Syntax Cheat Sheet

WhatSyntax
Start a pie chartpie
Titlepie title Visitors or a separate title … line
Slice"Search" : 58
Show values in the legendpie showData

Tips

  • Values must be 0 or more — a negative number is an error, and a 0 draws no slice.
  • Labels must be in double quotes.
  • Keep it to a handful of slices. With many small categories, group them into “Other” or use a table instead.
  • Slice colors come from the theme. Custom colors need theme variables (pie1, pie2…), which not every renderer allows.

More Mermaid guides: What is Mermaid, flowcharts, sequence diagrams, timelines, Gantt charts, class diagrams, ER diagrams and pie charts. To open .mmd files on a Mac, see how to open Mermaid files.

FAQ

How do I make a pie chart in Markdown?

Use a fenced code block with the language mermaid, start it with pie and add one line per slice: "Label" : 42. GitHub, Obsidian and MDViewer render it as a chart.

Do Mermaid pie chart values have to add up to 100?

No. Mermaid sums all values and calculates each slice’s share, so you can use raw counts.

How do I show numbers on a Mermaid pie chart?

Write pie showData instead of pie. The values appear next to the labels in the legend.

Can I change pie chart colors in Mermaid?

Only through theme variables such as pie1…pie12 in a Mermaid init or config block. Some renderers, including GitHub, limit custom themes.

View It with MDViewer

MDViewer renders Mermaid diagrams inside any .md file on your Mac — click a diagram to zoom and pan. Paste an example from this guide into a file and open it, or try it without installing in the free online viewer.

Download MDViewer

Lite is free for personal use; Pro is $9.99 one-time. Requires macOS 13.0 or later, Intel and Apple Silicon.