Mermaid Pie Chart Maker
Write pie charts in Mermaid code and watch them render as you type. Start from the example below, then export PNG or SVG, share a link or embed the diagram.
Updated · Code editor with live preview
Pie chart example
Rendering preview…
pie title Where the marketing budget went
"Paid search" : 42
"Content" : 27
"Events" : 19
"Everything else" : 12What is a pie chart?
A pie chart is a circle split into slices, where each slice shows one part of a whole and the size of the slice shows how big that part is. In Mermaid you write a pie chart as text: a title, then one line per slice with its label and value. Mermaid works out the percentages for you.
When to use a pie chart
- Budget and spend breakdowns
- Traffic or revenue by channel
- Survey results
- Any share-of-total figure in a report or slide
How to make a pie chart in Mermaid
- Step 1
Open the editor
Open TryMermaid with the example on this page, or start a new diagram with pie on the first line.
- Step 2
Name the chart
Add a title after the pie keyword, such as pie title Where the budget went.
- Step 3
Add the slices
Write one line per slice as a quoted label, a colon and a number, such as "Paid search" : 42. Mermaid turns the numbers into percentages.
- Step 4
Export or share
Check the live preview, then export the chart as PNG or SVG or copy a share link.
Pie chart syntax cheat sheet
| Element | Syntax | What it does |
|---|---|---|
| Start | pie | Begins a pie chart |
| Title | pie title Budget split | Heading above the chart |
| Slice | "Paid search" : 42 | One labelled value |
| Show values | pie showData title Budget | Prints each value in the legend |
| Decimals | "Referrals" : 12.5 | Values can be fractional |
Pie chart FAQ
Do the values in a Mermaid pie chart have to add up to 100?
No. Give each slice its raw value and Mermaid converts it to a percentage of the total. Writing 42 and 27 produces the same chart as writing the equivalent percentages.
How do I show the numbers on a Mermaid pie chart?
Add showData after the pie keyword, as in pie showData title Budget. Mermaid then prints each slice value next to its label in the legend.
Can I change the colors of the slices?
Slice colors come from the diagram theme. Change theme in the front matter, for example to forest or dark, and the palette changes with it.