Mermaid syntax checker & fixer · Rules, not AI · Runs locally

Fix Mermaid syntax errors

Paste broken Mermaid code from ChatGPT or Claude — we fix common syntax errors in your browser.

Why AI-generated Mermaid breaks

Language models write Mermaid from memory, and the parser is strict. One pair of parentheses in a label, a node called end or a -> arrow is enough to stop the whole diagram from rendering, and the parser's error — “Expecting 'SQE', got 'PS'” — is no help to most people. This page checks your Mermaid syntax, explains the problem in plain words and repairs the common mistakes automatically.

How the fixer works

  1. Your code is rendered with Mermaid 10.9.1 in the browser. If it fails, the error is translated and the line is highlighted in the editor.
  2. Repair rules run one at a time. After every rule that changes something, the diagram is rendered again, and the fixer stops as soon as it works.
  3. You see a line-by-line diff and the list of rules that were used. Nothing changes until you click Apply fix, and Undo fix brings the original back.

The rules are deterministic and run locally — no AI model is called and your code never leaves the page. On our test set of 120+ broken diagrams written in the style of ChatGPT, Claude and Gemini answers, the rules repair about nine in ten.

Common Mermaid syntax errors and how to fix them

Each row shows the kind of code that fails, and the version the fixer produces. They also work as a quick Mermaid diagram syntax reference if you prefer to fix things by hand.

ProblemFailsWorks
Markdown code fence around the code```mermaid flowchart TD A --> B ```flowchart TD A --> B
Brackets or parentheses inside a labelA[Start (init)] --> BA["Start (init)"] --> B
Double quotes inside a labelA[Click "Buy"] --> BA["Click #quot;Buy#quot;"] --> B
Lowercase end used as a nodeA --> endA --> endNode
Full-width punctuation in syntaxA[开始] → B A->>B:hiA[开始] --> B A->>B: hi
Single-dash arrow in a flowchartA -> BA --> B
Broken edge labelA -->|yes|> BA -->|yes| B
Subgraph title with spaces or symbolssubgraph Client Side (React)subgraph g1["Client Side (React)"]
Missing diagram typeA --> Bflowchart TD A --> B
Wrong case or direction in the type lineFlowchart top-downflowchart TD
Explanation text around the codeHere is the diagram: flowchart TD A --> Bflowchart TD A --> B
graph keyword with newer syntaxgraph TDflowchart TD
Invisible characters from chat appsA​ --> B (zero-width space)A --> B
Spaces in node IDsUser Login --> HomeUser_Login["User Login"] --> Home
Unclosed subgraph or loopsubgraph API A --> Bsubgraph API A --> B end
Sequence message without a colonClient->>Server GET /healthClient->>Server: GET /health
Unquoted ER relationship labelUSER ||--o{ ORDER : places, cancelsUSER ||--o{ ORDER : "places, cancels"
Unquoted pie label or % valueChrome : 65%"Chrome" : 65
New shape syntax on Mermaid 10db@{ shape: cyl }db[("db")]

When the rules cannot fix it

Some errors need a human: a label that is cut off halfway, a reference to a task that does not exist, or a deactivate without a matching activate. In those cases the error explanation and the highlighted line tell you where to look. Once it renders, export it with Mermaid to SVG or Mermaid to PNG, or keep editing in the Mermaid viewer.

FAQ

Does the fixer use AI?

No. It applies a fixed set of repair rules in your browser and checks each change with the real Mermaid parser. Nothing is sent to an AI service or to our servers.

Will it change what my diagram means?

The rules only change syntax — quoting, arrows, punctuation, reserved words. You always see a diff of every change and decide whether to apply it, and you can undo it afterwards.

What if it cannot fix my diagram?

You still get a plain-English explanation and the error line is highlighted in the editor. The common errors table on this page shows the correct syntax for each case.

Why does ChatGPT produce broken Mermaid code?

Models mix syntax from different Mermaid versions and forget that labels with brackets need quotes or that end is reserved. These are exactly the mistakes the fixer targets.

Can I check syntax without changing anything?

Yes. Paste the code and read the status above the editor. The fixer only suggests changes; applying them is always your choice.