Sequence Diagram Online Editor
Draw sequence diagrams online with Mermaid: participants, async messages, loops, alt blocks and notes, with live preview and free PNG, SVG and PDF export.
Try it
Edit the code; the preview updates as you type.
Rendering diagram…
What is a sequence diagram?
A sequence diagram shows how people and systems talk to each other over time. Each participant gets a vertical lifeline, and every message is an arrow between two lifelines, read from top to bottom.
Mermaid describes the whole diagram in plain text that starts with sequenceDiagram. Edit the example in the playground above and the preview redraws as you type; nothing is uploaded and no account is needed.
When to use it
- API request and response flows between a client, a gateway and services
- Login, OAuth and payment handshakes where the order of calls matters
- Explaining retries, timeouts and error branches in a code review or design doc
- Documenting message queues and asynchronous events
- Support runbooks that show who calls whom during an incident
Mermaid sequence diagram syntax
Every diagram of this type starts with sequenceDiagram.
| Syntax | Meaning |
|---|---|
participant A as Alice | Declares a participant with a short ID and a display name; use actor for a person icon. |
A->>B: Text | Solid line with an arrowhead: a request or call. |
A-->>B: Text | Dotted line with an arrowhead: a reply or return value. |
A-)B: Text | Open arrow for an asynchronous message such as an event. |
A-xB: Text | Line ending in a cross: a failed or rejected message. |
A->>+B / B-->>-A | The + and - suffixes start and end an activation bar on the receiver. |
Note right of A: Text | Adds a note beside one participant, or over A,B to span two. |
alt / else / end | Alternative branches; opt, loop, par, critical and break use the same block form. |
autonumber | Numbers every message automatically. |
More examples
Retry loop with an asynchronous event
sequenceDiagram
participant S as Checkout
participant P as Payment API
participant Q as Event Bus
loop Up to 3 attempts
S->>P: Charge card
P-->>S: Timeout
end
S-)Q: payment.failed
Q-)S: Notify customerCommon mistakes and how to fix them
- A message is missing its colon, for example A->>B Hello.
- Every message needs a colon before its text: A->>B: Hello.
- An alt, loop or opt block never closes.
- Close every block with end on its own line; nested blocks need one end each.
- The word end inside a message breaks the diagram.
- Wrap it in quotes or brackets, for example A->>B: (end) of session.
- Deactivating a participant that is not active.
- Pair every + with a later - on the same participant, or remove the suffixes.
Export your sequence diagram
Download a PNG, SVG or PDF straight from the playground above. For more options, such as a 1x to 4x scale, a transparent background or copying the image, choose Open in editor and use the Export menu there. Export is free, needs no account and adds no watermark.
Frequently asked questions
How do I make a sequence diagram in Mermaid?
Start the code with sequenceDiagram, optionally declare participants, then write one message per line such as Client->>Server: GET /orders. The preview on this page draws the diagram as you type.
What is the difference between ->> and -->> in Mermaid?
->> draws a solid line and is normally used for a call or request. -->> draws a dotted line and is normally used for the reply. Both end in an arrowhead.
Can I number the messages automatically?
Yes. Add autonumber on the line after sequenceDiagram and every message gets a sequence number.
How do I export a sequence diagram as an image?
Click PNG, SVG or PDF in the playground at the top of this page. For a 1x to 4x scale or a transparent background, open the diagram in the editor and use its Export menu. Export is free and adds no watermark.