← Back to editor

Mermaid error

The first line must declare the diagram type

Reproduced on Mermaid 11.17.2 · Updated

The first line must declare the diagram type in Mermaid. The exact parser message, why it happens, and corrected source that renders.

What Mermaid says

No diagram type detected matching given configuration for text: Request --> Approve
  Approve --> Deploy

Why it happens

Mermaid chooses a parser from the first token. With only arrows in the block there is no diagram type to parse against, so nothing matches.

The source that fails

  Request --> Approve
  Approve --> Deploy

How to fix it

Put the diagram keyword, and for a flowchart its direction, on the first line.

flowchart TD
  Request --> Approve
  Approve --> Deploy

Next steps

Paste your own version into the Mermaid repair tool, which applies this correction and fourteen others and shows every change. The related page covers the surrounding syntax, and the error dictionary lists every message.