All tutorials

Mermaid Sequence Diagram with Examples

Copy a Mermaid sequenceDiagram and edit it in the browser. The examples below cover participants, solid and dashed messages, activation, loops, and alt fragments.

Define who or what is involved in the interaction. Use `participant` for objects/services and `actor` for human representations.

sequenceDiagram
    actor User
    participant Browser
    participant Server
    participant Database

Live Editor

Unsaved
Ready
Loading Monaco Editor...
Preview
Styling
Sequence Diagram

Frequently asked questions

What is a Mermaid sequenceDiagram?

A sequenceDiagram is a Mermaid diagram of messages between participants in time order. The first line is the keyword sequenceDiagram. Each later line is a participant or a message such as User->>Server: Request.

How do I write a Mermaid sequence diagram?

Start with sequenceDiagram, declare participants, then write messages. ->> is a solid call and -->> is a dashed reply. Wrap repeated calls in loop and branches in alt/else/end. The examples on this page are editable.

What is the difference between ->> and -->> ?

->> draws a solid arrow, usually the request. -->> draws a dashed arrow, usually the response. The labels after the colon are the message text, such as Request or JWT token.

How do loops and alt fragments work?

loop repeats the messages inside it until end. alt / else splits a choice, such as Has updates versus No updates, and also closes with end. opt is the optional form and par runs branches together.

More Tutorials

All tutorials