The Mermaid code my AI gave me won't render. Now what?
About 3 min · Updated 2026-09-13
Work out which of three things it is: a syntax error, a diagram language that isn't Mermaid, or a diagram past the engine's edge limit. The fix is different for each, and the error bar tells you which.
Short answer
Paste it into the editor. The status line turns into an error bar in plain language with a line number. Three cases cover it.
Case 1: a syntax error
Errors mentioning Parse error or Lexical error are syntax. Generated code has four recurring weak spots — the reserved word end, mixed arrow styles, full-width punctuation, and quotes inside labels. Each one is written up in What does Parse error mean.
If you'd rather not hunt: the error bar has "AI fix". It sends the current code to the engine once, makes the smallest change that parses, verifies the result renders before showing it to you, and presents a line-by-line diff to accept or discard.
Case 2: it isn't Mermaid
Models sometimes hand back PlantUML or Graphviz dot when you asked for Mermaid, and sometimes use syntax from a newer release. Quick check: the first line should be one of flowchart / graph / sequenceDiagram / classDiagram / stateDiagram-v2 / erDiagram / mindmap / gantt / pie. If it's none of those, go back and ask for Mermaid specifically.
Case 3: the diagram is too big
Past 500 edges the engine refuses the flowchart outright — that error is a limit, not a syntax problem. Splitting is the only fix: break it into stages, or collapse the detail layer. Around 300 nodes takes about a second to lay out, which is normal.
What a clean one looks like
stateDiagram-v2
[*] --> AwaitingPayment
AwaitingPayment --> Paid: payment captured
AwaitingPayment --> Cancelled: 30 min timeout
Paid --> Shipped: left the warehouse
Shipped --> Complete: delivery confirmed
Complete --> [*]More guides
- How do I get a flowchart from ChatGPT into a Word document?
- Do I have to strip the code block out of the AI reply?
- How do I put a Mermaid diagram into PowerPoint?
- What does "Parse error" mean in Mermaid, and how do I fix it?
All guidesLooking for a specific answer? Try the Help Center