← Back to editor

Mermaid error

A pie slice value must be a number

Reproduced on Mermaid 11.17.2 · Updated

A pie slice value must be a number in Mermaid. The exact parser message, why it happens, and corrected source that renders.

What Mermaid says

Parsing failed: Lexer error on line 2, column 14: unexpected character: ->t<- at offset: 31, skipped 3 characters. Parse error on line 2, column 17: Expecting token of type 'NUMBER_PIE' but found `
`.

Why it happens

Each slice is a quoted label, a colon and a number. A word in the value position is rejected by the lexer before the chart is built.

The source that fails

pie title Traffic
  "Search" : ten

How to fix it

Write the value as a number.

pie title Traffic
  "Search" : 55
  "Direct" : 45

Next steps

Paste your own version into the Mermaid repair tool, which applies this correction and fourteen others and shows every change. The related page covers the surrounding syntax, and the error dictionary lists every message.