The notation, a filled-in example you can copy, and the Mermaid code that draws it.
A sequence diagram is a UML diagram that shows how people and systems exchange messages in one scenario, in the order they happen. Each participant gets a lifeline running down the page, and each message is an arrow from one lifeline to another, so you read it from top to bottom. To draw one, pick a single scenario, line the participants up left to right, then add the messages, replies and branches in time order.
Figure 1Parts of a sequence diagram. The five parts on a small coffee order, with the four message types numbered separately, so eight notes in all. Time runs down the page, and the line style and label tell you whether the sender waits.
The diagram, top to bottom
The parts
A sequence diagram is an interaction diagram from UML, the Unified Modeling Language: it shows one scenario as messages passed between participants, ordered by time. Wikipedia sums it up as a diagram that “shows process interactions arranged in time sequence” (Wikipedia). Sequence diagrams are sometimes called event diagrams or event scenarios.
UML groups its 14 diagram types into structure diagrams and behavior diagrams, and the sequence diagram sits in the interaction subset of behavior diagrams with the communication, timing and interaction overview diagrams (Wikipedia, UML). The current standard is UML 2.5.1, published by the Object Management Group in December 2017 (OMG). For the other 13 types, see our overview of UML diagrams.
Visual Paradigm’s guide puts it plainly, time in a sequence diagram is about ordering, not duration (Visual Paradigm). Two arrows far apart may be a millisecond apart.
Use a sequence diagram when the question is who talks to whom, and in what order: designing an API call, explaining an integration with a payment provider, or finding the race in async code. A sequence diagram is the wrong tool when the question is what happens next in a process with many decisions. That’s a flowchart’s job.
Good fits:
A sequence diagram has five parts: participants, lifelines, messages, activation bars and combined fragments. Participants sit along the top, each with a lifeline dropping down the page. Messages are arrows between lifelines, activation bars show who is busy, and combined fragments are frames that add branches and loops. Messages come in four common types:
Message type | How it’s drawn | What it means |
|---|---|---|
Synchronous | Solid line, filled arrowhead | The sender waits for the answer, like a function call |
Asynchronous | Solid line, open arrowhead | The sender carries on without waiting, like an event on a queue |
Reply | Dashed line, open or filled arrowhead | A result going back to whoever asked |
Self message | An arrow that loops back to its own lifeline | A participant calling itself |
UML has a few rarer messages too: a create message that starts a new participant’s lifeline partway down, a destroy message that ends a lifeline with an X, and found and lost messages that come from, or go to, somewhere outside the diagram.
The arrowhead and line style tell you whether the sender waits. In Wikipedia’s words, “Solid arrow heads represent synchronous calls, open arrow heads represent asynchronous messages, and dashed lines represent reply messages” (Wikipedia). A synchronous caller “must wait until the message is done”; an asynchronous one “can continue processing and need not wait for a response”.
The dashed line is what makes a reply: UML 2.5.1 says a reply “has a dashed line with either an open or filled arrow head” (UML specification, p. 577 (page 619 of the PDF)), and the figures here use the filled one. Some guides draw asynchronous messages as dashed lines too. In UML that reads as a reply, so a dashed arrow with no request before it looks like an answer to nothing.
The figures in this guide are live boards whose sequence diagrams have one arrowhead, filled, so they mark each asynchronous message in its label instead, as (async). When you draw your own, the open arrowhead or the label both work, as long as the whole diagram uses one.
An activation bar is the thin rectangle on a lifeline that shows a participant is busy handling a message. It starts when the message arrives and ends when the participant sends its reply or finishes. UML’s formal name for it is an execution specification (Wikipedia). Activation bars are optional, but they make it obvious who is holding things up.
A combined fragment is a frame around a group of messages, with an operator in its top left corner that says how they run. Conditions, called guards, go in square brackets, such as [card approved]. IBM’s guide compares alt to if-then-else logic and opt to a simple if-then statement (IBM Developer). The four you’ll use most:
UML has more operators, such as break for an exit from the scenario, critical for a section that can’t be interrupted, and ref for a reference to another sequence diagram.
Here’s a filled-in sequence diagram for a coffee shop app. A customer orders a flat white for pickup, the orders API charges the card, and on success it sends the order to the barista’s tablet. It covers two outcomes in one alt fragment: the card is approved, or it’s declined.
Figure 2Sequence diagram example: ordering a coffee ahead. New order #142 (async) is the message to notice: it's asynchronous, so the orders API confirms the order without waiting for the barista. The board is the Mermaid code further down, so you can copy either one.
Participants: Customer (actor), Coffee app, Orders API, Payment provider, Barista tablet.
alt [card approved]
else [card declined]
Read a sequence diagram from top to bottom, one arrow at a time, and say each one out loud as a sentence: “the coffee app sends POST /orders to the orders API, and waits”. When you reach a frame, read its guard first, then only the section that applies. Inside an alt frame only one section runs, so an activation bar that ends at a reply is drawn through both sections and stops at the reply in the last one.
In the example, the first three messages always happen. Then the alt frame splits: on an approved card, the orders API sends the order to the barista and confirms it to the app; on a declined card, it returns 402 and the app asks for another card. New order #142 is the message worth a second look. The orders API doesn’t wait for the barista to accept the order, so the customer sees “Ready in 5 min” straight away. If the tablet is offline, nobody is told. That’s the kind of gap a sequence diagram makes visible before it ships.
To create a sequence diagram, pick one scenario, put its participants in a row in the order they first act, then add the messages top to bottom with a reply under each synchronous call. Add frames for branches last, and check the diagram against the code or the people who own each participant.
In Whimsical, press S for diagram shapes and pick the sequence diagram actor, or search for it in the All tools menu with /. You can also paste Mermaid code onto a board, as shown further down. Getting started with sequence diagrams has the details, and the UML sequence diagram template is a finished example to start from.
A good message label names what is asked or sent, with the detail that matters: the route, the amount, the order number or the status code. Most weak labels are generic verbs like “request” or “response”, which tell the reader an arrow exists but not what it carries. Here are four labels as they often get written, and as the example writes them:
Coffee app → Orders API: Send request
Call: Coffee app → Orders API: POST /orders
Orders API → Payment provider: Payment
Call: Orders API → Payment provider: Charge card $4.50
Orders API → Barista tablet: Update
Async message: Orders API → Barista tablet: New order #142 (async)
Orders API → Coffee app: Response
Reply: Orders API → Coffee app: 402 Payment failed
A sequence diagram shows who sends what to whom, in order, for one scenario. A flowchart, or its UML cousin the activity diagram, shows the steps and decisions of a process without saying which participant does each step. Pick by the question you’re answering: “who talks to whom?” needs a sequence diagram, “what happens next?” needs a flowchart.
Figure 3Which diagram should you draw: sequence, flowchart, communication or state? One question, four answers. If your question is who talks to whom, and in what order, draw a sequence diagram; if it's what happens next, a flowchart.
What do you need to show?
Here’s how the sequence diagram compares with the two you’ll choose between most often:
Sequence diagram | Flowchart or activity diagram | Communication diagram | |
|---|---|---|---|
Shows | Messages between participants, in time order | Steps and decisions in a process | Links between participants, with numbered messages |
Laid out by | Participants across, time down | Flow from step to step | Freely, like an object diagram |
Best for | API calls, integrations, async behavior | Business processes, algorithms | Seeing who is connected to whom |
Weak at | Many branches and decisions | Who does each step, unless you add swimlanes | Following the order of messages |
A communication diagram carries much of the same information as a sequence diagram, but keeps order only through numbers on each message. Wikipedia’s comparison: communication diagrams show which elements interact better, while sequence diagrams show “the order in which the interactions take place more clearly” (Wikipedia).
To make a sequence diagram from Mermaid code, start with the sequenceDiagram keyword, declare each participant, then write one message per line in the form Sender->>Receiver: label. Mermaid, a text syntax for diagrams, uses ->> for a solid arrow, -->> for a dotted reply, -) for an asynchronous message, + and - for activations, and alt, opt, loop and par for frames (Mermaid docs). This is Figure 2 as Mermaid:
Paste that code onto a Whimsical board with Command + V (Mac) or Control + V (PC) and you get an editable sequence diagram with notes, frames and activation bars, not a picture (Mermaid article). It works the other way too: select the diagram and choose Copy as… → Mermaid to take it back out as code for a pull request or a README.
Figure 2 is that code, pasted: all five participants, the alt frame with its declined branch, both activation bars and all ten labels come through. One thing doesn’t: -) pastes with the same filled arrowhead as ->>, hence the (async) in its label.
Yes. ChatGPT, Claude and coding agents like Cursor write good Mermaid sequence diagrams from a description or straight from code, because calls, routes and events are all there in the source. We’d check two things before sharing one: whether each arrow really waits, which a model can’t always tell from the code, and whether the error paths are real or invented.
With the Whimsical MCP, the assistant draws the sequence diagram straight onto a Whimsical board instead of handing you code to paste. In Cursor, Claude Code or another coding agent with the MCP connected, this prompt asks for the same notation as the example above:
The seven UML structure diagrams are the class, component, composite structure, deployment, object, package and profile diagrams. They show what a system is made of. A sequence diagram isn’t one of them: it’s a behavior diagram, in the interaction group with the communication, timing and interaction overview diagrams.
A system sequence diagram treats the whole system as one black box, a single lifeline called System, and shows only the messages that cross its boundary from the actors. It’s drawn early, for a use case’s main success scenario, before anyone decides which classes or services sit inside the box.
No. A sequence diagram shows the order of messages, not their duration: a long gap between two arrows doesn’t mean a long wait. When timing matters, write it on the diagram as a note, or draw a UML timing diagram, which is built around timing constraints.
In UML, a sequence diagram uses dashed lines for two things. The vertical dashed line under each participant is its lifeline, the participant’s existence over time, though some tools, including the figures here, draw it solid. A horizontal dashed arrow is a reply message, carrying a result back to whoever sent the request.
Draw one sequence diagram per scenario worth explaining. A short branch, like the declined card in the example above, fits inside the same diagram as an alt fragment. A branch with its own long chain of messages, such as a refund, is clearer as a separate diagram than as a frame inside a frame.
Map your own call flow
The UML sequence diagram template is a finished example: a task runner's run() call across six lifelines, with guards, an exception and a retry. Copy it and swap in your own participants.
Open the UML sequence diagram template