Atlas
  • All-in-one
  • Solutions
  • Compare
  • Pricing
PricingGet started
All guides
July 5, 2026·11 min read·mermaid, sequence diagram, tutorial, diagram as code

Mermaid Sequence Diagram Tutorial (With Syntax)

Sequence diagrams show how parts of a system talk to each other over time. Mermaid makes them fast to write and easy to keep current.

A sequence diagram shows how different participants - users, services, systems - interact over time, with messages passing between them in order. It is one of the most useful diagrams in software design because it makes the choreography of a system concrete: who calls whom, in what order, and what comes back. Mermaid's sequence diagram syntax is particularly clean, and once you know it you can capture an interaction in the time it takes to describe it in words.

This tutorial builds a sequence diagram step by step, introducing each syntax feature with a small, correct snippet you can copy. We will cover participants, the different message arrow types, activations, loops and conditionals, and notes. By the end you will be able to read and write real sequence diagrams. You can try every snippet live in the editor at /diagram-tools/mermaid-editor, or explore the dedicated sequence tooling at /diagram-tools/sequence-diagram.

Participants and the first message

Every sequence diagram starts with the declaration `sequenceDiagram` on its own line. Below that, you describe interactions. The simplest possible diagram is a single message between two participants: `Alice->>John: Hello John`. That one line creates two participants, Alice and John, draws a vertical lifeline for each, and shows a solid arrow carrying the message "Hello John" from Alice to John. Mermaid infers the participants from the messages, so you often do not need to declare them separately.

You can declare participants explicitly if you want to control their order or give them aliases. Writing `participant A as Alice` lets you refer to the participant as `A` in messages while displaying "Alice" in the diagram, which keeps long message lines readable. Declaring participants up front also fixes the left-to-right order they appear in, rather than letting Mermaid order them by first appearance - useful when you want a specific arrangement.

Message arrow types

Mermaid distinguishes several kinds of messages through the arrow syntax, and using the right one communicates intent. A solid arrow with a filled head, written `->>`, is a synchronous call - the sender waits for a response. A dashed arrow, written `-->>`, is typically a response or return message. These two are the workhorses: `Alice->>John: Ask question` followed by `John-->>Alice: Give answer` reads as a request and its reply.

  • `->>` solid line with arrowhead: a synchronous call or request.
  • `-->>` dashed line with arrowhead: a response or return message.
  • `->` solid line without arrowhead: a simple signal or asynchronous message.
  • `-->` dashed line without arrowhead: an async response or a weaker relationship.
  • `-x` solid line ending in a cross: a message that is lost or fails.
  • `-)` solid line with an open arrowhead: an asynchronous message (fire-and-forget).
  • The text after the colon is always the message label describing what is being communicated.

Activations, loops, and conditionals

Activations show when a participant is actively processing. You turn one on and off by appending `+` and `-` to messages: `Alice->>+John: Request` activates John's lifeline (drawn as a thin bar), and `John-->>-Alice: Response` deactivates it. The activation bar makes it visually clear how long John is busy handling the request, which matters in diagrams with nested calls where you want to see how deep the call stack goes.

For repetition and branching, Mermaid provides block constructs. A `loop` block repeats a set of messages: you write `loop Every minute`, then the messages inside, then `end`. Conditionals use `alt` and `else`: `alt Payment valid` for one branch, `else Payment declined` for the other, closed with `end`. There is also `opt` for an optional block that may or may not happen, and `par` for messages that occur in parallel. These blocks draw labelled frames around the relevant messages, so the control flow of the interaction is visible at a glance.

Notes and grouping

Notes add explanatory text to a diagram. You place a note over a participant or spanning several with syntax like `Note over Alice: She is thinking` or `Note over Alice,John: They negotiate`. Notes are invaluable for annotating why something happens, not just what - a message shows the call, and a note can explain the business rule behind it. You can also position a note to the left or right of a participant with `Note left of` and `Note right of`.

For larger diagrams, you can group participants into boxes to show they belong to the same system or team, and use dividers to mark phases of the interaction. As with all Mermaid, the layout is automatic - you never position a lifeline or route a message by hand, you just declare the interaction and Mermaid draws it cleanly. When your sequence diagram grows complex or you want to fine-tune its appearance for a presentation, you can bring it into the visual canvas at /diagrams, or keep iterating in the live Mermaid editor at /diagram-tools/mermaid-editor where you see the rendered result update as you type.

Keep reading

  • Best Diagramming Software in 2026: The Overall Buyer Guide
  • How to Make Diagrams for Confluence
  • How to Make Diagrams for Notion
  • Free PDF tools
  • The all-in-one work OS

FAQ

Questions, answered.

How do I start a sequence diagram in Mermaid?
Begin with the keyword sequenceDiagram on its own line, then write messages like Alice->>John: Hello. Mermaid automatically creates participants from the messages and draws their lifelines. You can optionally declare participants explicitly with the participant keyword to control their order or give them shorter aliases for readable message lines.
What is the difference between the arrow types in Mermaid sequence diagrams?
A solid arrow ->> is a synchronous call, a dashed arrow -->> is a response or return, a plain -> is a simple signal, -x shows a lost or failed message, and -) shows an asynchronous fire-and-forget message. Choosing the right arrow communicates whether the sender waits, whether it is a reply, and whether the call is synchronous or async.
How do I show a loop or a condition in a Mermaid sequence diagram?
Use block constructs. A loop block (loop ... end) repeats messages. Conditionals use alt and else (alt ... else ... end) for either-or branches. There is also opt for an optional block and par for parallel messages. Each draws a labelled frame around its messages so the control flow is visible at a glance.
What are activations in a sequence diagram?
Activations show when a participant is actively processing a request, drawn as a thin bar on the lifeline. In Mermaid you activate with a + and deactivate with a - appended to messages, like Alice->>+John: Request and John-->>-Alice: Response. They make nested calls and how long a participant is busy visually clear.
Can I add explanatory notes to a Mermaid sequence diagram?
Yes. Use Note over, Note left of, or Note right of to attach text to one participant or span several, like Note over Alice,John: They negotiate. Notes let you explain why something happens, not just what, which is invaluable for documenting the business rules or context behind the messages.

Ready when you are

One workspace, not ten.

Atlas replaces the stack with one platform for tasks, projects, CRM, contracts, e-signature, PDF tools, and analytics. Start free.

Get started freeSee pricing
AtlasWork, planned itself.

The AI-native, all-in-one work platform. Tasks, projects, CRM, contracts, and analytics in one calm workspace.

All systems operational
  • SOC 2 II
  • ISO 27001
  • HIPAA
  • GDPR

Product

  • Overview
  • PDF tools
  • People & HR
  • Integrations
  • Marketplace
  • Pricing

Resources

  • Guides
  • Docs
  • API reference
  • Support
  • Changelog
  • Status

Company

  • About
  • Careers
  • Press
  • Contact

Legal & trust

  • Trust center
  • Security
  • Privacy
  • Terms
  • DPA
  • GDPR
  • SLA
  • Refunds
Atlas, a product by wrxstack.com·© 2026 wrxstack·All rights reserved
PrivacyTermsSecurityStatus