Guide
Fix Mermaid diagrams generated by ChatGPT
Chatbots write Mermaid that looks right and fails with “Parse error on line 3”. The mistakes are almost always the same handful. Here they are, with the exact message Mermaid prints for each, so you can recognise them at a glance.
Updated
flowchart TD
A["User opens app (mobile)"] --> B{Logged in?}
B -->|Yes| C["Show “Home”"]
B -->|No| D[Login page]
D --> E[Submit form]
E --> EndA typical broken answer
```mermaid
flowchart TD
A[User opens app (mobile)] --> B{Logged in?}
B -->|Yes| C[Show "Home"]
B -->|No| D[Login page]
D -> E[Submit form]
E --> end
```- The Markdown fence (the lines with three backticks) was copied too. It belongs to Markdown; a Mermaid editor sees it as text.
(mobile)inside[…]: parentheses start a round shape, so the label breaks."Home"inside[…]: straight double quotes inside an unquoted label.->has one dash; flowchart links need two (-->).endis a keyword (it closes subgraphs), not a node name.
The corrected version is drawn above. The Mermaid syntax checker opens with this exact sample and fixes all five in one click.
Error messages decoded
Look at the word after got at the end of the message. These are the messages printed by the Mermaid version Arrowly ships for each mistake.
| Message ends with | Usual cause | Fix |
|---|---|---|
got 'PS' | ( inside a label in […], (…) or |…| | Quote the label: A["Call (v2)"] |
got 'STR' | Double quotes inside an unquoted label | Quote the whole label and use “curly” quotes inside |
got 'end' | A node called end | Rename it End or done |
got 'MINUS' | -> in a flowchart | --> |
got 'NODE_STRING' | Space inside a node id (my node --> B) | myNode[My node] --> B |
got '1' | The parser reached the end: unclosed bracket or a subgraph without end | Close the bracket, add the end |
Expecting 'TXT', got 'NEWLINE' | Sequence message without a colon | A->>B: text |
... got 'NEWLINE' on a sequence line with ; | Semicolon inside a message | Replace it with a comma |
Lexical error ... Unrecognized text | A character Mermaid doesn't read there, often → | --> (flowchart) or ->> (sequence) |
No diagram type detected | Fence lines or no flowchart/sequenceDiagram on top | Remove the fence, add the type |
No such shape: … | Invented name in @{ shape: … } | Use a name from the shapes list |
Ask the chatbot for code that parses
If you keep generating diagrams in a chat, add these constraints to your prompt. They remove most of the errors above at the source.
Arrowly avoids the problem differently: its AI never writes Mermaid. It returns the boxes and arrows as data, and Arrowly writes the code from that, escaping every label, so the result always parses.
Skip the broken code entirely
Paste the notes you were going to give the chatbot. Arrowly draws the diagram and writes Mermaid that always parses, with a live editor and SVG/PNG export. 3 free diagrams a day, no signup.
Draw from my notesQuestions
Why does the same code work in ChatGPT's preview but not in my docs?
Different Mermaid versions. Newer versions accept syntax older ones reject (and occasionally the reverse). Check which version your docs tool runs, and prefer the classic syntax for portability.
Is it safe to paste internal diagrams into the checker?
Yes. The checker parses and draws in your browser; the code is not uploaded.