Mermaid Diagram Not Rendering? 10 Common Errors and How to Fix Them

Parse error on line 3, blank output, arrows that turn into circles: the ten Mermaid mistakes behind most broken diagrams, what each error message means, and the one-line fix for each.

9 min read

A Mermaid diagram that will not render almost always fails for one of a small number of reasons. The error message looks cryptic (Parse error on line 4: ... Expecting 'SQE', 'DOUBLECIRCLEEND') but the cause behind it is usually a single character.

This post lists the ten failures that account for most broken diagrams, in rough order of frequency. For each one: what you see, why the parser rejects it, and the fix. If you paste the broken code into the MermanDraw editor, it marks the failing line, and for the first seven it offers a "Fix automatically" button.

1. Markdown fences pasted with the code

Symptom: Parse error on line 1, or the renderer says it cannot detect the diagram type. The code came from a chat window or a README, and the first line is three backticks followed by mermaid.

Why: the fences are Markdown, not Mermaid. GitHub and Notion strip them for you; a bare renderer does not.

```mermaid
flowchart TD
    A[Start] --> B[Finish]
```
Remove the first and last lines before rendering. MermanDraw strips them on paste.

2. Smart quotes from a docs tool

Symptom: a parse error pointing at a quoted label that looks correct. Copying from Google Docs, Word, Notion, or Slack often converts " into “ and ”.

Why: Mermaid only treats the straight ASCII double quote as a string delimiter. The curly characters are ordinary text, so the label is unquoted and the parser trips over whatever is inside it.

flowchart LR
    A["Draft"] --> B["Review"]
    B -->|"approved"| C["Publish"]
Mermaid diagram

approved

Draft

Review

Publish

Straight quotes only. Turn off smart quotes in the editor you draft in.
Try in editor →

3. Unicode arrows and en-dashes

Symptom: a parse error on a line that contains an arrow. The arrow is →, or it is –> with an en-dash instead of two hyphens.

Why: word processors replace -- with a dash automatically, and some AI models output the real arrow glyph. Mermaid recognizes -->, ---, -.->, ==> and a few others, all built from ASCII characters.

flowchart LR
    Request --> Validate --> Save
    Save --> Respond
Mermaid diagram

Request

Validate

Save

Respond

Two hyphens and a greater-than sign. Nothing else.
Try in editor →

4. Parentheses, brackets, or colons inside a label

Symptom: Parse error on a node such as A[Click (here)] or B[Step 2: confirm].

Why: in a flowchart, parentheses and brackets are shape syntax. A[Click (here)] reads to the parser like a rectangle that suddenly tries to open a rounded shape. Colons, pipes and semicolons have meanings too.

Fix: wrap the label text in double quotes. Inside quotes, any character is allowed except another double quote (use #quot; for that).

flowchart TD
    A["Click (here)"] --> B["Step 2: confirm"]
    B --> C["Array[0] item"]
Mermaid diagram

Click (here)

Step 2: confirm

Array[0] item

Quoted labels can contain parentheses, brackets, and colons.
Try in editor →

5. A reserved word used as a node id

Symptom: a flowchart that ends with a node called end fails, or a diagram with a node id of subgraph, style, class, click, or direction fails on that line.

Why: these words are keywords. end closes a subgraph, so C --> end is read as "close the subgraph" in the middle of an edge. Lowercase end is the one that catches people, because it is the natural name for the last step.

Fix: use a different id and put the display text in the label. The id never shows on the diagram, so finish([End]) gives you the word "End" on screen without the keyword.

flowchart TD
    start([Start]) --> work[Do the work]
    work --> finish([End])
Mermaid diagram

Start

Do the work

End

Ids are internal. Only the label is displayed.
Try in editor →

6. An o or x right after the arrow

Symptom: the diagram renders, but an edge has a circle or a cross on its end that you never asked for. Or a parse error on an edge into a node whose id begins with o or x.

Why: --o and --x are edge styles in flowcharts (circle end and cross end). So A --oOrder, or A ---xray with no space, is read as a styled edge followed by a half-id.

Fix: put a space between the arrow and the node id, or capitalize the id. A --- oOrder still has the problem; A --- Order or A --- B[option one] does not.

flowchart LR
    A --- B[option one]
    A --- C[xray result]
    A --> D[Order placed]
Mermaid diagram

A

option one

xray result

Order placed

Keep a space after the arrow and avoid ids that start with a lowercase o or x.
Try in editor →

7. A literal \n for a line break

Symptom: the label shows a backslash and an n, or the diagram fails to parse. The code came from a programming context where \n means newline.

Why: Mermaid labels are HTML-ish text. The escape sequence is not interpreted.

Fix: use <br/> inside a quoted label. This works in flowcharts, sequence diagram messages, and most other types.

flowchart TD
    A["First line<br/>Second line"] --> B["Single line"]
Mermaid diagram

First line
Second line

Single line

A br tag inside a quoted label is the portable way to break lines.
Try in editor →

8. The wrong arrow family for the diagram type

Symptom: a sequence diagram with --> arrows renders dashed lines without arrowheads, or a class diagram with --> for inheritance shows a plain association. Sometimes the parser rejects the line outright.

Why: every diagram type has its own arrow grammar. Flowcharts use -->. Sequence diagrams use ->> for a call and -->> for a reply. Class diagrams use <|-- for inheritance, *-- for composition, and o-- for aggregation. AI models mix these up when they switch types mid-answer.

sequenceDiagram
    participant C as Client
    participant S as Server
    C->>S: GET /items
    S-->>C: 200 OK
Mermaid diagramServerClientServerClientGET /items200 OK
Sequence diagram: two angle brackets make a solid arrowhead, dashes make the line dashed.
Try in editor →
classDiagram
    class Animal {
        +String name
        +speak()
    }
    class Dog
    Animal <|-- Dog
Mermaid diagram

Animal

+String name

+speak()

Dog

Class diagram: the triangle points at the parent.
Try in editor →

The sequence, class and flowchart guides each list the full arrow table for that type.

9. Indentation in mindmaps, missing dateFormat in Gantt charts

Symptom (mindmap): nodes attach to the wrong parent or the parser complains about an unexpected indentation. The code was indented with tabs, or a child is indented less than its parent.

Why: mindmaps are the one Mermaid type where whitespace carries meaning. Depth is the indentation level. Mixing tabs and spaces gives inconsistent depths.

mindmap
  root((Launch plan))
    Marketing
      Landing page
      Newsletter
    Engineering
      Beta build
Mermaid diagram

Launch plan

Marketing

Landing page

Newsletter

Engineering

Beta build

Two spaces per level, spaces only, every child deeper than its parent.
Try in editor →

Symptom (Gantt): tasks fail to parse or land on the wrong dates. The chart has no dateFormat line, or the dates in the tasks do not match it.

Why: Gantt dates are parsed with the format you declare. Without a declaration the default is YYYY-MM-DD, and a task written as 11/02/2026 is rejected.

gantt
    title Sprint 12
    dateFormat YYYY-MM-DD
    section Build
    API endpoints   :a1, 2026-11-02, 4d
    UI integration  :after a1, 3d
Mermaid diagram2026-11-022026-11-022026-11-032026-11-032026-11-042026-11-042026-11-052026-11-052026-11-062026-11-062026-11-072026-11-072026-11-082026-11-082026-11-09API endpoints UI integration BuildSprint 12
Declare the format once, then write every date the same way.
Try in editor →

See the mindmap guide and the Gantt guide for the remaining rules.

10. A wrong or missing diagram keyword on line 1

Symptom: No diagram type detected, or a parse error on line 1. The first line is sequencediagram (lowercase d), flow chart TD, erdiagram, or the keyword is missing because only the body was copied.

Why: the first non-empty line selects the parser. Keywords are case-sensitive: sequenceDiagram, classDiagram, erDiagram, stateDiagram-v2, flowchart, gantt, mindmap, timeline, pie.

A note on graph vs flowchart: graph TD still works and is not an error. But some newer features (markdown strings, certain shapes) only work with flowchart. If an AI gives you graph, changing it to flowchart is safe.

sequenceDiagram
    Alice->>Bob: Hello
    Bob-->>Alice: Hi
Mermaid diagramBobAliceBobAliceHelloHi
Capital D. The parser will not guess.
Try in editor →

A fast debugging routine

  1. Paste the code into the editor. Read the line number in the error panel, not the "expecting" list.
  2. If a "Fix automatically" button appears, click it. It covers errors 1 through 4 and 7.
  3. Look at the named line for a reserved word, a lowercase o/x after an arrow, or an arrow from another diagram type.
  4. Still stuck? Delete lines from the bottom until it renders, then add them back one at a time. The first line that breaks it is the problem.

Working examples of every type are in the cheatsheet and the examples gallery. Starting from one that renders and editing it is faster than fixing a long diagram from scratch.

FAQ

What does "Parse error on line N" mean in Mermaid?

The parser read your code line by line and hit a token it could not place on that line. The line number is reliable; the column and the "expecting" list are less useful. Look at the named line and the one above it for an unclosed bracket, a reserved word, or a stray character.

Why does my diagram render in one tool but not another?

Tools bundle different Mermaid versions. Newer diagram types (architecture, block, sankey, xychart) and newer syntax need a recent version. If a diagram works in MermanDraw but fails in Notion or a docs site, the host is probably on an older Mermaid.

Can MermanDraw fix these errors for me?

Partly. The editor highlights the failing line, and when the problem is one of the mechanical ones (markdown fences, smart quotes, unicode arrows, unquoted parentheses, literal \n) a "Fix automatically" button rewrites the code. Logic errors like a reserved word or the wrong arrow family still need a hand edit.

The diagram renders but looks wrong. Is that a syntax error?

Usually not. Overlapping labels, a node in an odd place, or the wrong direction are layout issues. Change the direction keyword (TD, LR), adjust node and rank spacing in the Layout panel, or split the diagram into subgraphs.

Related