Mermaid validator and syntax checker

Paste Mermaid code and find out at once whether it is valid. If it is not, you get the line and column of the error, the line highlighted, and a hint at what usually causes it. Free, and nothing leaves your browser.

flowchart TD
    A[Start] --> B{Is it valid?}
    B -->|Yes| C[Ship it]
    B -->|No| D[Fix line 4]
    D --> B
Loading the tool…

How to do it

  1. Step 1

    Paste your code

    Paste your diagram into the box above, or upload a .mmd or Markdown file.

  2. Step 2

    Read the result

    The code is checked as you type; the result shows valid or the error.

  3. Step 3

    Jump to the line

    Click the line number in the error to jump to it; the line is highlighted.

  4. Step 4

    Fix and continue

    Fix it, check the hint if the message is unclear, and open the result in the editor.

Reading the error message

Mermaid reports errors like "Parse error on line 4: ...B --> C( got PS". The position in that message can count from the wrong place when the diagram has front matter or directives, so the tool maps it back to the matching line of the code you pasted, the same way the TryMermaid editor does.

Fixing the usual suspects

Wrap any label that contains brackets, parentheses, quotes or other punctuation in double quotes: A["Save (draft)"]. Inside quotes, write a double quote as #quot;. Avoid end as a node id in flowcharts; End or END is fine.

Validating automatically

Run the validator in a pull request check with the Mermaid CLI, or let an AI assistant call TryMermaid's MCP server, which validates every diagram before saving it.

What this does not do

  • The validator checks syntax, not meaning: a diagram can be valid and still have a node you forgot to connect.
  • Errors come from Mermaid's parser, whose messages are terse. The hints cover the common cases, not every one.
  • It checks against the Mermaid version TryMermaid ships (11.x). A platform pinned to an old Mermaid version may reject newer syntax that passes here.

Frequently asked questions

How does the validator check my diagram?

It runs your code through the same Mermaid parser (Mermaid 11) that renders diagrams in TryMermaid and in tools like GitHub, so an error here is an error there. When the parser fails, the tool reports its message with the line and column, highlights the line and adds a hint for the most common causes.

Why does the error point at the wrong line?

Mermaid's parser reports where it noticed the problem, which can be one line after the real mistake, for example when a bracket opened on line 3 is never closed. Look at the highlighted line and the one above it.

What are the most common Mermaid syntax errors?

The usual causes are: a label with parentheses or brackets that is not in double quotes, the reserved word end used as a node id, curly quotes pasted from a word processor, a missing diagram type on the first line, and in sequence diagrams a message without a colon. The hints below the result check for each of these.

Does it check every diagram type?

Yes. Every diagram type Mermaid supports is checked: flowchart, sequence, class, state, ER, Gantt, pie, mind map, timeline, Git graph, C4, sankey, XY chart, block, packet, architecture and the rest.

Can an AI agent use this validator?

Yes. The TryMermaid MCP server has a trymermaid_validate_diagram tool that uses the same parser, so Claude, Cursor or another agent can check a diagram before saving it. See the MCP documentation.

More Mermaid tools

All tools