← Back to editor

Mermaid error

Reserved words cannot be node identifiers

Reproduced on Mermaid 11.17.2 · Updated

Reserved words cannot be node identifiers in Mermaid. The exact parser message, why it happens, and corrected source that renders.

What Mermaid says

Parse error on line 2:
flowchart TD  graph --> B[Next]
--------------^
Expecting 'SEMI', 'NEWLINE', 'SPACE', 'EOF', 'subgraph', 'end', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'AMP', 'COLON', 'STYLE', 'LINKSTYLE', 'CLASSDEF', 'CLASS', 'CLICK', 'DOWN', 'DEFAULT', 'NUM', 'COMMA', 'NODE_STRING', 'BRKT', 'MINUS', 'MULT', 'UNICODE_TEXT', 'direction_tb', 'direction_bt', 'direction_rl', 'direction_lr', 'direction_td', got 'GRAPH'

Why it happens

Words such as graph, class and style begin statements. Used as an identifier they start the statement they name, and the rest of the line becomes unexpected input.

The source that fails

flowchart TD
  graph --> B[Next]

How to fix it

Rename the identifier and put the word in the label instead.

flowchart TD
  chart["graph"] --> B[Next]

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.