Common errors and how to fix them

Updated 2026-10-22

When the pasted code has a syntax problem, the bar under the editor explains it in plain language with a line number. Click “Go to line N” to jump there; the preview keeps the last good render until it is fixed. The bar also offers “AI fix”, which shows a diff and checks the result locally before you apply it. The sections below follow the messages you may see.

Edges are written as -->; -> is not a Mermaid arrow

Flowchart edges use two dashes: A --> B. The single-dash -> only appears in sequence diagrams (A->>B). Replace -> with --> on that line.

end is a reserved word

end closes subgraph, loop and similar blocks, so it cannot be a node name. Use End or END, or give it a label: e1[end].

Unclosed bracket

[ needs ], ( needs ), { needs }. The usual cause is brackets inside the node text, for example A[Login (phone)]. Wrap the text in double quotes: A["Login (phone)"].

This line contains a full-width character

Mermaid only accepts half-width (ASCII) punctuation in syntax positions. Replace ():,; with () : , ;. Punctuation inside node text is fine; only the characters that act as syntax matter. The bar tells you which character it found.

No diagram type found

The first line has to be a diagram keyword: flowchart TD, graph LR, sequenceDiagram, classDiagram, stateDiagram-v2, gantt, pie, mindmap and so on. Assistants sometimes mention the keyword in the prose instead of the code. Add it as the first line.

A subgraph or block is missing its closing end

Every subgraph, loop, alt, opt and par needs an end line. The line number points at the end of the code because the parser reached the end without finding it.

Incomplete message line

Sequence diagram messages need all their parts: A->>B: message text. The arrow has to be followed by a participant, and the text comes after the colon.

Incomplete relationship symbol

ER diagram relationships need a cardinality on both ends, for example USER ||--o{ ORDER : has. Leaving out one side of ||, o{ or }| triggers this message.

A mind map can have only one root node

Mind maps are structured by indentation: mindmap on the first line, a single root such as root((Topic)) on the second, and every level below indented two more spaces. A second top-level node, or a root indented deeper than its branches, triggers this message; the bar names the node. A stray end line is treated as a second root as well.

Diagram too large: more than 500 edges

This is not a syntax error but a safety limit of the renderer. Split the diagram by module or trim the branches. A diagram this size does not fit on one page in any tool.

A reversed link can't carry a label

Links like A <-- text --- B or A <-. text .- B (arrowhead on the left, label in the middle) pass the syntax check, but the renderer can't draw them. Swap the two ends and write the link forwards: B -- text --> A (dotted: B -. text .-> A); the arrow still points at A. Unlabelled A <-- B and two-way A <-->|text| B are fine. The “Fix it” button on the error bar swaps them for you.

In linkStyle 3 stroke:red, 3 is the link's position: links are numbered from 0 in the order they appear in the code. After you delete or rearrange links, an old number may no longer exist. Remove the out-of-range numbers, or use linkStyle default stroke:red to style every link.

A group shares its name with a node

If subgraph A1[...] contains a node that is also called A1, or a link inside a group points at the group itself, the diagram contains a loop. Give the group a different id, e.g. subgraph A1_group["Title"]. In class diagrams, don't give a namespace the same name as a class inside it.

A group has no id

Groups written with a title but no id, such as subgraph [" "], fail to render when there is more than one. Add an id before the bracket: subgraph g1[" "], and give each group its own id.

The Gantt chart date can't be read

Task dates must follow the format in dateFormat, e.g. dateFormat YYYY-MM-DD with 2026-10-01. AI replies sometimes use a dash that looks the same but isn't (such as 2026‑10‑01); replace it with a plain -.

Sequence diagram activations don't pair up

In A->>+B the + activates the receiver B, and in B-->>-A the - deactivates the sender B (activate / deactivate work the same way); they must pair up. AI replies often activate one participant and deactivate another, which makes rendering fail. “Fix it” removes the unmatched -, keeping every message and dropping only that activation bar.

Syntax error on this line

The fallback message when none of the above applies. It quotes the text near the problem. Common causes: unpaired arrows, brackets or quotes; special characters such as | or " inside node text (wrap the text in double quotes); pie chart rows that are not written as "label" : value.

This line contains a character Mermaid can't read

Usually a special or invisible character that came along when copying from a web page. Delete the line and retype it.

The diagram code has a syntax error

The fallback when no line number is available. Check arrows, brackets and indentation, or click “AI fix”.

Open the editor

Related articles