Skip to main content

Error: "This diagram has an error"

Symptom​

Instead of the diagram, people who can edit it see This diagram has an error on line and a line number, with an Edit diagram button. Readers who can't edit see This diagram can't be shown.

In the editor, the preview shows The diagram has an error on line and a line number.

Cause​

The diagram code has a Mermaid syntax error, so Mermaid can't draw it. Common causes:

  • A missing closing bracket, such as A[Start instead of A[Start].
  • A misspelled diagram type on the first line, such as flowchartt.
  • Wrong indentation in a mindmap or timeline, where indentation sets the structure.
  • More than one --- config block, or a config block that isn't the first thing in the code.
  • Syntax from a Mermaid version newer than 12.1.

Solution​

  1. Select Edit diagram in the message. The editor opens and shows Mermaid's explanation of the error.

  2. In the preview, select Go to line. The line is underlined in the code.

    The preview showing that the diagram has an error on line 3, with a Go to line 3 link

  3. Correct the code. The preview draws the diagram as soon as the error is gone.

  4. Select Save and close.

To check the syntax for a diagram type, see Supported diagram types. To find the error faster, paste the code into the Mermaid Live Editor, which uses the same Mermaid version.

Still not working?​

Contact support with the diagram code and the error message.