Skip to content

Sequence Diagram

Last updated:

Mermaid Studio provides full language support for Sequence diagrams inside IntelliJ IDEA and other JetBrains IDEs. Sequence diagrams show how processes interact with each other over time, and are essential for documenting API flows, system integrations, and protocol specifications.

Syntax highlighting integrates directly with IntelliJ’s color scheme system, so diagram colors always match your editor theme.

Sequence diagram syntax highlighting in Armada Dark theme

The summary below shows the IDE support Mermaid Studio ships for sequence diagrams, grouped by capability.

IDE feature supportSelect a feature for its description.
Editing
Code Intelligence
Validation
Refactoring
Navigation & Docs
Appearance
Visual Editing

Highlighting extends into the embedded JSON of properties and links blocks, and completion filters out top-level-only keywords inside control-flow blocks where Mermaid.js wouldn’t accept them. Parse errors are isolated per block body, so a mistake inside one alt or loop never cascades through the rest of the file.

Turn on Edit Mode (pencil icon) in the editor toolbar and you can build and rearrange a sequence diagram directly in the preview. Every edit is written back to the source as ordinary Mermaid.js syntax, and Command + Z Control + Z undoes it like any other change. See Visual Editing for what edit mode shares across diagram types, such as selection and navigation to source.

In the clip below, a message’s text is edited in place, then two messages are wrapped in a loop with Command + G Control + G :

The diagram actions toolbar in the corner of the preview adds a participant or sets up numbering:

The sequence diagram actions toolbar with the Add Participant and Autonumber buttons

  • Add Participant opens a picker of the participant types, from a plain participant to an actor, database, or queue, and declares the new participant with its display name ready to type.
  • Autonumber turns message numbering on or off and sets its start and step.

Everything else starts from a lifeline. Hover a lifeline and a + appears in each gap between messages. Drag a + across to another lifeline to add a message there, or drag it down along its own lifeline to add an activation.

Right-click a lifeline for the full set of additions at that point, as shown here for the API lifeline:

The right-click menu of the API lifeline with Add Message To, Add Note, Create Participant, Destroy Here, and Activate Here

A new message, note, or participant opens its text for editing straight away, so you can type the label without reaching for the mouse.

Double-click an element, or select it and press Enter Enter , to edit its text in place, such as a message’s text or a fragment’s condition. Editing a display name writes as and never changes the participant’s ID, so use the Rename refactoring to change the ID itself.

Pickers change what an element is, such as a participant’s type or a message’s arrow. With several elements of the same kind selected, a picker applies to all of them.

A rect or box gets its color from swatches derived from the diagram’s theme, so the color you pick suits both the theme and the lifelines drawn over it. The CSS color field takes any other color:

The Color popover of a selected rect, with a Default chip, two rows of theme swatches, and a CSS color field

Drag a participant’s header sideways to reorder the participants, or drag it across a box’s edge to move it into or out of the box. Drag a message, note, or fragment up or down to move it, including into and out of a fragment’s sections. A selected message shows a grip at each end; drag one onto another lifeline to change the sender or recipient. A selected over note has grips to stretch it across more lifelines, and a selected activation bar has handles to change where it starts and ends.

The same moves work from the keyboard, so you can step an element one place at a time with the shortcuts in the action reference.

Command + G Control + G groups the selection the way the selection allows:

  • Messages, notes, and fragments — Wrap in Fragment opens a picker of fragment kinds, from loop and alt to rect. Type a kind’s first letter to pick it, then type the condition.
  • Participants in adjacent columns — Group into Box wraps them in a new box and opens its title for editing.

Command + Shift + G Control + Shift + G reverses either one: it unwraps a fragment or box, keeping the statements and participants inside, or removes a participant from its box. On an alt, par, or critical fragment, Add Section appends an else, and, or option section.

Every action is in the element’s right-click menu. Press Period Period for a quick-action menu under the selected element, and the most common actions also appear in the floating toolbar above the selection. The quick-action menu lists each action with its shortcut, as here for a selected message:

The quick-action menu of a selected message, listing Edit Text, Change Arrow, Wrap in Fragment, the move actions, Reverse Direction, Delete, and Select Siblings with their shortcuts

You can rebind any of the shortcuts below in Settings > Keymap (search for “Mermaid”).

Option + Shift + P Alt + Shift + P , Option + Shift + C Alt + Shift + C , and Option + Shift + S Alt + Shift + S select the parent, children, or siblings of the selected element, following the source’s nesting of fragments, sections, and boxes. Tab Tab and Shift + Tab Shift + Tab step through the elements in source order.

ActionShortcut or gesture
Edit Display NameDouble-click or Enter Enter
Change Type…Menu
Move Left / Move Right Option + Left Arrow Alt + Left Arrow / Option + Right Arrow Alt + Right Arrow , or drag the header
Group into Box Command + G Control + G
Remove from Box Command + Shift + G Control + Shift + G
Delete Backspace Delete

Deleting a participant also removes its messages, activations, and create and destroy lines.

ActionShortcut or gesture
Edit TextDouble-click or Enter Enter
Change Arrow…Menu
Move Up / Move Down Option + Up Arrow Alt + Up Arrow / Option + Down Arrow Alt + Down Arrow , or drag the message
Move Recipient Left / Right Option + Left Arrow Alt + Left Arrow / Option + Right Arrow Alt + Right Arrow , or drag the end grip
Move Sender Left / Right Option + Shift + Left Arrow Alt + Shift + Left Arrow / Option + Shift + Right Arrow Alt + Shift + Right Arrow , or drag the end grip
Reverse DirectionMenu (no default shortcut)
Wrap in Fragment… Command + G Control + G
Delete Backspace Delete
ActionShortcut or gesture
Edit TextDouble-click or Enter Enter
Change Placement…Menu
Move Up / Move Down Option + Up Arrow Alt + Up Arrow / Option + Down Arrow Alt + Down Arrow , or drag the note
Stretch across lifelinesDrag the grips of an over note
Wrap in Fragment… Command + G Control + G
Delete Backspace Delete

These actions apply to every fragment kind except rect, which has its own entry below. Select a fragment by its label tab or its frame.

ActionShortcut or gesture
Edit ConditionDouble-click or Enter Enter
Change Type…Menu
Add SectionMenu (alt, par, and critical)
Move Up / Move Down Option + Up Arrow Alt + Up Arrow / Option + Down Arrow Alt + Down Arrow , or drag the fragment
Wrap in Fragment… Command + G Control + G
Unwrap Command + Shift + G Control + Shift + G or Backspace Delete

A section is an else, and, or option part of a fragment after its first.

ActionShortcut or gesture
Edit LabelDouble-click or Enter Enter
Remove Section Backspace Delete

Removing a section merges its statements into the section above.

A rect takes the fragment actions above, except that it has no condition: double-click or Enter Enter opens Edit Color… instead.

ActionShortcut or gesture
Edit TitleDouble-click or Enter Enter
Edit Color…Menu
Unwrap Command + Shift + G Control + Shift + G or Backspace Delete
ActionShortcut or gesture
Change start or endDrag the bar’s top or bottom handle
Delete Backspace Delete

Dropping a handle on a message writes a + or - marker on it; dropping it between messages writes an activate or deactivate line.

ActionShortcut or gesture
Add a messageDrag a + across to another lifeline, or Add Message To in the menu
Add an activationDrag a + down the lifeline, or Activate Here in the menu
Add NoteMenu
Create ParticipantMenu
Destroy HereMenu

A set of 31 context-aware live templates scaffolds the block keywords, participant and actor declarations, notes, messages, and autonumber statements that sequence diagrams use day-to-day. Type a short abbreviation, accept it from the completion popup, and tab through the template variables.

Individual abbreviations can be toggled under Settings > Tools > Mermaid Studio > Live Templates in the Sequence Diagram group. See Live Templates for the cross-cutting mechanics (triggering, contextual visibility, configuration).

AbbreviationExpansion
blooploop ... end
baltalt ... else ... end
boptopt ... end
bparpar ... and ... end
bcritcritical ... option ... end
bbrkbreak ... end
bboxParticipant grouping box (box ... end)
brectBackground rectangle (rect rgb(...) ... end)
AbbreviationExpansion
nlNote left of participant
nrNote right of participant
noNote over participant

The prta and atra templates produce as-aliased declarations; cprta and catra produce the create variants. The prj and atj templates use the typed-metadata @{type: ...} form (Mermaid.js 11.13.0+); cprj and catj produce the create variants of those.

AbbreviationExpansion
prtaparticipant X as "Label"
atraactor X as "Label"
cprtacreate participant X as "Label"
catracreate actor X as "Label"
prjparticipant X@{type: ...} (11.13.0+)
atjactor X@{type: ...} (11.13.0+)
cprjcreate participant X@{type: ...}
catjcreate actor X@{type: ...}

msg is the generic form: it expands the arrow as a picker variable, so you choose the operator on insert. The other ten templates each hard-code one operator for when you already know the shape you want.

AbbreviationExpansion
msgMessage with arrow picker (A -> B: text)
msSolid line, no arrowhead (A -> B: text)
msfSolid line with arrowhead (A ->> B: text)
mdDotted line, no arrowhead (A --> B: text)
mdfDotted line with arrowhead (A -->> B: text)
mcSolid line with cross (A -x B: text)
mdcDotted line with cross (A --x B: text)
maAsync solid arrow (A -) B: text)
mdaAsync dotted arrow (A --) B: text)
mbBidirectional solid (A <<->> B: text)
mdbBidirectional dotted (A <<-->> B: text)
AbbreviationExpansion
autnsautonumber 10 10 (start + step)
sequenceDiagram
participant A as Alice
participant B as Bob
A->>B: Hello
SyntaxMeaning
->Solid line
-->Dashed line
->>Solid with arrowhead
-->>Dashed with arrowhead
-xSolid with cross
--xDashed with cross
<->>Bidirectional
-)Half-arrow (Mermaid.js 11.13.0+)
--)Dashed half-arrow (Mermaid.js 11.13.0+)
sequenceDiagram
Client->>+Server: Request
Server-->>-Client: Response
sequenceDiagram
Alice->>Bob: Hello
Note right of Bob: Bob thinks
Bob-->>Alice: Hi!

For full syntax details, see the Mermaid.js sequence diagram documentation.