← Back to editor

Mermaid error

A subgraph needs a title on the same line

Reproduced on Mermaid 11.17.2 · Updated

A subgraph needs a title on the same line in Mermaid. The exact parser message, why it happens, and corrected source that renders.

What Mermaid says

Cannot read properties of undefined (reading 'text')

Why it happens

The subgraph keyword expects an identifier or a title after it. With nothing there, the renderer has no label to read and fails before it draws anything.

The source that fails

flowchart TD
  subgraph
    A --> B
  end

How to fix it

Give the subgraph a title, quoting it when it contains spaces.

flowchart TD
  subgraph Team
    A --> B
  end

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.