Mermaid Syntax Errors: Common Causes and How to Fix Them
Mermaid error messages are short and full of parser jargon. Once you know how to read them, most errors come down to a dozen recurring causes, and each one has a quick fix.
Quick check: paste your code into the free Mermaid syntax checker to see the failing line highlighted, with a fix suggestion.
How to read a Mermaid parse error
A typical flowchart error looks like this:
Diagram
flowchart LR
A[Start] --> B[Retry (3x)]
Error
Parse error on line 2:
...[Start] --> B[Retry (3x)]
-----------------------^
Expecting 'SQE', 'DOUBLECIRCLEEND', 'PE', '-)', 'STADIUMEND',
'SUBROUTINEEND', 'PIPE', 'CYLINDEREND', 'DIAMOND_STOP', ...,
got 'PS'
It has three useful parts:
- The line number tells you where the parser gave up. The real mistake is usually on that line, but sometimes it is an unclosed bracket or block a few lines earlier.
- The caret (
^) points at the exact character where parsing stopped. - "got 'X'" is the token Mermaid found instead of what it expected. In flowcharts,
PSandPEare opening and closing parentheses,SQSandSQEare square brackets,DIAMOND_STARTis{, andPIPEis|.
In the example above, the parser saw a ( inside a square-bracket label. That is the first and most common cause below.
1. Special characters in labels
Brackets, parentheses, and braces define node shapes, so using them inside a label confuses the parser. Wrap the label in double quotes and Mermaid treats everything inside as text.
Broken
flowchart LR
A[Start] --> B[Retry (3x)]
Fixed: quote labels with special characters
Double quotes make the parentheses part of the label instead of a shape.
flowchart LR
A[Start] --> B["Retry (3x)"]
B --> C["Response {status: 200}"]2. "No diagram type detected"
The full message is No diagram type detected matching given configuration for text. Mermaid reads the first line to decide which diagram it is drawing, so the first line must be a diagram keyword such as flowchart TD, sequenceDiagram, or erDiagram. Common causes:
- A typo or wrong casing:
flowchar,sequencediagram, orERDiagram. Keywords are case-sensitive. - The Markdown fence was pasted too. Remove the
```mermaidand closing```lines when you paste into an editor. - A diagram type that the renderer's Mermaid version does not support yet.
3. Using the word "end" in a flowchart
end closes a subgraph, so a node labeled with lowercase end breaks the flowchart. Capitalize it or put it in quotes.
Broken
flowchart TD
start --> end
Fixed: capitalize or quote "end"
Any capitalization other than all-lowercase works, and so does a quoted label.
flowchart TD
start --> process --> finish["end"]4. Node IDs that start with "o" or "x"
In flowcharts, --o and --x are link types with a circle or a cross at the end. So A---oB draws a circle-ended link to B, not a link to a node called oB. Add a space before the node ID or capitalize its first letter.
Unexpected result
flowchart LR
dev---ops
Fixed
flowchart LR
dev --- ops
5. A missing "end"
Every subgraph in a flowchart and every alt, opt, loop, par, critical, and rect block in a sequence diagram needs a closing end. The error usually points at the last line of the diagram, because that is where the parser notices the block was never closed. Indent your blocks so a missing end is easy to spot.
6. Smart quotes and invisible characters
Code copied from Word, Google Docs, Notion, or a chat app often contains curly quotes (“ ”) instead of straight quotes ("), or non-breaking spaces that look like normal spaces. Mermaid does not treat them as quotes or whitespace. If a line looks correct but still fails, retype its quotes and spaces by hand.
7. Semicolons and colons in text
- In sequence diagrams, a semicolon ends a statement, so text after it is lost or causes an error. Write
#59;instead of;. - In Gantt charts, the colon separates the task name from its data. Remove colons from task names.
Fixed: an escaped semicolon in a message
The entity code #59; renders as a semicolon without ending the statement.
sequenceDiagram
Client->>API: GET /items#59; limit=20
API-->>Client: 200 OK8. Gantt dates that do not match dateFormat
Gantt task dates should match the dateFormat line. This mistake is sneaky because Mermaid often does not report an error: a date written as 12/01/2026 under dateFormat YYYY-MM-DD can be read as a different day, so tasks quietly land in the wrong place. If a Gantt chart renders but the bars look wrong, check that every date uses exactly the declared format, such as 2026-12-01.
9. Inconsistent indentation in mindmaps
Mindmaps use indentation to build the tree, and there can only be one root. A second line at the root's indentation level, or a mix of tabs and spaces, produces an error or a node attached to the wrong parent. Use spaces only, and keep siblings at exactly the same indentation.
10. Angle brackets for generics in class diagrams
Class diagrams use tildes for generic types. Write List~string~ rather than List<string>.
11. Missing labels and spaces in ER diagrams
Every ER relationship needs a label after the colon, and entity names cannot contain spaces. CUSTOMER ||--o{ ORDER fails, while CUSTOMER ||--o{ ORDER : places works. Use ORDER_ITEM, not ORDER ITEM.
12. It works in one tool but not another
GitHub, GitLab, Notion, Obsidian, and documentation generators each bundle their own Mermaid version, and some lag well behind the latest release. Newer syntax, such as recently added diagram types or node shapes, fails on older renderers. If a diagram renders in an editor but not on your platform, check the platform's Mermaid version, or rewrite the diagram using older syntax.
A fast debugging routine
- Look at the line the error points to, then at the lines just above it.
- Check every label that contains a symbol and wrap it in double quotes.
- If you still cannot find it, delete half of the diagram. If the error disappears, the problem is in the half you removed. Repeat until you find the line.
- Rebuild the full diagram from the smallest version that renders.
In Mermaid Preview, the preview keeps showing the last diagram that rendered while the error is displayed below it, so you can see what changed while you fix the code.
Try it in Mermaid Preview: Paste the diagram that is failing into the live editor. The preview shows the error and the line it points to as you type.
Open the editor →