Fix Mermaid code that will not render
Paste the code that fails and the editor repairs the breakages that generated Mermaid arrives with, showing exactly what it changed before anything replaces your diagram.
Nothing is rewritten silently. The repair runs on the text you paste, lists every change, and shows the result; your current diagram is only replaced when you accept it, and Undo brings it back.
How it works
- Paste the failing code into the repair box and choose Check code.
- Read the list of changes. Each line says what was repaired and how many times.
- Choose Use the fixed code to load it into the editor, or edit the text and check again.
- If it still fails, the status bar reports the line Mermaid objected to. Undo always restores the previous diagram.
What breaks in generated Mermaid
Language models produce Mermaid that is nearly right. The recurring failures are mechanical: a Markdown code fence left around the block, a sentence of explanation above it, curly quotation marks from a word processor, an unquoted label containing brackets or a comma, the reserved word end used as a node, an arrow written as -> instead of -->, an unclosed <br>, a subgraph with no end, a Gantt chart with dates but no dateFormat, or a mindmap indented with tabs.
Before and after
This block fails on four separate counts: the fence, the -> arrow, the unquoted bracketed label and the reserved word.
```mermaid\ngraph TD\n A[Start (here)] -> B{Ready?}\n B -->|yes| end\n```The repair produces valid source with the same meaning, renaming only what Mermaid refuses to accept.
graph TD\n A["Start (here)"] --> B{Ready?}\n B -->|yes| endNodeWhy the reserved words matter
Mermaid reads a bare lowercase end as the token that closes a subgraph, so using it as a node identifier ends the block early and the rest of the diagram becomes a parse error on a line that looks fine. The repair renames the node and leaves the visible label alone. The same applies to graph and subgraph as identifiers.
Frequently asked questions
Does the fixer change my diagram without asking?
No. It works on the text in the repair box, lists every change and shows the result. Your diagram is replaced only when you accept it, and that replacement is a single Undo step.
What does it fix?
Fifteen rules: Markdown fences, explanatory prose above the code, non-breaking spaces, curly quotation marks, unclosed line breaks, a missing diagram type, a duplicated diagram type, broken flowchart arrows, labels needing quotes, the reserved word end, unclosed subgraphs, tab-indented mindmaps, missing Gantt date formats, multi-word sequence participants, and trailing whitespace.
Will it change code that already works?
No. Every rule is a no-op on valid Mermaid, and that is checked against the whole example library on each build. If nothing needs repairing, the fixer says so and leaves the text alone.
Keep reading
Fix diagram errors · the example library · all guides
mermaid.tools is an independent editor not affiliated with the Mermaid.js project or Mermaid Chart / mermaid.ai. Everything on this page runs in your browser with Mermaid 11.17.2.