Error reference / sequenceDiagram

sequenceDiagram parse error: missing end for a block

An alt, loop, opt, par, critical, or break block was opened but never closed, so the parser runs out of diagram before it finds the matching end.

Parse error on line 6:
...       A->>A: tick
---------------------^
Expecting 'SPACE', 'NEWLINE', 'INVALID', 'create', 'box', 'end', ... 'loop', 'rect', 'opt', 'alt', 'par', ... got '1'

Why this happens

alt, loop, opt, par, critical, and break all open a block that must be closed with its own end, the same way subgraph does in flowcharts. Forgetting the end -- often after deleting or reordering lines during an edit -- leaves the parser expecting more content that never arrives.

The error appears at the end of the file (or the next sibling block), not at the line that actually opened the unclosed block, which makes it easy to miss on a quick read.

How to fix it

Add the missing end after the block's last message. For nested blocks (an alt inside a loop, for example), count opens and closes -- each one needs its own end, innermost first.

Broken

Fails to parse

Rendering preview...
sequenceDiagram
    participant A
    loop every 5s
        A->>A: tick

Fixed

Renders correctly

Rendering preview...
sequenceDiagram
    participant A
    loop every 5s
        A->>A: tick
    end
Open fixed version in studio

More errors