Unsaved
Ready
Loading Monaco Editor...
Preview
Styling
Pie Chart
All diagram types

Mermaid Pie Chart Syntax & Data Examples

A pie chart shows how a total splits across a handful of categories. Each line is one slice.

Examples

Copy an example, or open it in the live editor with this diagram already loaded.

Support ticket mix

showData prints the counts you typed. Mermaid converts them to shares of the total.

pie showData
    title Support tickets this week
    "Editor" : 42
    "Export" : 18
    "Billing" : 16
    "Sign-in" : 11
    "Other" : 7

Budget shares

The values are dollars, not percentages. A slice's angle is its share of the sum.

pie showData
    title Q2 budget
    "Engineering" : 480
    "Support" : 160
    "Marketing" : 140
    "Operations" : 90

Survey with an Other bucket

Small answers are grouped so the chart stays readable. Five slices is usually the limit.

pie showData
    title How did you find the editor
    "Search" : 46
    "Docs" : 22
    "A teammate" : 18
    "Social" : 8
    "Other" : 6

What is a Pie Chart?

A Mermaid pie chart draws one slice per labeled value. Mermaid totals the numbers and sizes each slice as its share of that total, so the values do not need to add up to 100. showData prints the raw number next to the label. Keep the chart to a few slices. A pie chart answers 'what share is this?' and it is a poor fit for a trend, a ranking of many items, or two series.

When to use it

Use a pie chart for a mix that sums to one whole: traffic sources, budget shares, or ticket categories. Use an XY chart when you are comparing values over time or across many categories. Use a Sankey diagram when the story is how a quantity splits and then splits again.

Edit this pie chart in the live editor, read the Mermaid cheat sheet, or compare it with Flowchart, Gantt Chart and Mind Map.

Common Use Cases

  • •Market share visualization - Show competitive landscape
  • •Budget allocation - Display spending by category
  • •Survey results - Present response distributions
  • •Portfolio composition - Visualize asset allocation
  • •Resource usage - Show how resources are divided

Syntax Quick Reference

ElementSyntaxDescription
Titletitle Chart TitleChart heading
Data item"Label" : valueAdd a slice
Show datashowDataPrint the raw value beside each slice
Multiple itemsOne per lineEach line is a slice

Syntax tips

  • •The first line is pie, or pie showData if you want the raw numbers beside the labels.
  • •title goes on its own line. Slice lines look like "Label" : 42. Quote labels that contain spaces.
  • •Values are relative. 1, 1, and 2 draw the same chart as 25, 25, and 50.
  • •Group anything under a few percent into Other. Thin slices are hard to tell apart.
  • •There is no time axis. If the question is 'how did this change by month?', use an XY chart.

Common mistakes

Entering percentages that already sum to 100 and also expecting Mermaid to treat them as extra metadata.

Mermaid only sees the numbers. If the numbers are already percentages, they still work, because only the ratios matter.

Adding a seventh slice for every small category.

Fold the tail into Other. A pie chart with many slivers stops being readable.

Using a pie chart for a trend.

A pie has no x-axis. Plot the series on an XY chart instead.

Export Options

Pie charts are compact, so PNG is usually enough for a slide. Use SVG when the chart sits in a docs page. Free PNG exports include a watermark.

Got Mermaid code from ChatGPT? Paste it here to render and export instantly.

Get the Free Mermaid Syntax Cheat Sheet

Free Mermaid Syntax Cheat Sheet

All 21 diagram types in one PDF reference.

Frequently Asked Questions

Ready to create your own pie chart?

Open the editor with this example pre-loaded and start customizing.

Pie Chart templates

Related Diagram Types

All diagram types