Skip to content

Sequence Diagram

Sequence diagrams are the first — and currently only — fully implemented diagram type in plantuml.rs. This page documents the supported syntax with live examples rendered to SVG at build time.

Use -> for a solid arrow and --> for a dashed arrow. Participants are inferred from the messages.

AliceBobAliceBobAliceBobhellohi
Source
@startuml
Alice -> Bob: hello
Bob --> Alice: hi
@enduml

Declare participants explicitly to control their left-to-right order. Use participant, actor, or other keywords.

AliceBobAliceBobAliceBobRequestResponse
Source
@startuml
participant Alice
participant Bob
Alice -> Bob: Request
Bob --> Alice: Response
@enduml
UserSystemUserSystemUserSystemloginwelcome
Source
@startuml
actor User
User -> System: login
System --> User: welcome
@enduml

A participant can send a message to itself.

AliceAliceAliceself message
Source
@startuml
Alice -> Alice: self message
@enduml

Add notes with the note keyword. Place them left of, right of, or over a participant.

AliceBobAliceBobAliceBobhello
Source
@startuml
Alice -> Bob: hello
note right of Alice: says hello
Bob --> Alice: hi
note right of Bob: replies
@enduml

Notes can span multiple participants with note over:

AliceBobAliceBobAliceBobhello
Source
@startuml
Alice -> Bob: hello
note over Alice, Bob: both
@enduml

Use activate and deactivate to show lifeline activation.

AliceBobAliceBobAliceBobrequestresponse
Source
@startuml
Alice -> Bob: request
activate Bob
Bob --> Alice: response
deactivate Bob
@enduml

Group messages with group/end, or use the alt/else/end and loop/end constructs.

AliceBobAliceBobAliceBobAuthenticationcredentialstoken
Source
@startuml
group Authentication
Alice -> Bob: credentials
Bob --> Alice: token
end
@enduml
AliceBobAliceBobAliceBobalt[success]ok[failure]fail
Source
@startuml
alt success
Alice -> Bob: ok
else failure
Alice -> Bob: fail
end
@enduml
AliceBobAliceBobAliceBobloop[until done]checknot yet
Source
@startuml
loop until done
Alice -> Bob: check
Bob --> Alice: not yet
end
@enduml

Use == to insert a divider between groups of messages.

AliceBobAliceBobAliceBobstep 1step 2
Source
@startuml
Alice -> Bob: step 1
== Phase 2 ==
Bob -> Alice: step 2
@enduml

Use autonumber to automatically number messages.

AliceBobAliceBobAliceBobfirstsecond
Source
@startuml
autonumber
Alice -> Bob: first
Bob --> Alice: second
@enduml

Set a title with the title keyword.

My SequenceAliceBobAliceBobAliceBobhello
Source
@startuml
title My Sequence
Alice -> Bob: hello
@enduml

Customize appearance with skinparam. For example, set the background color.

AliceBobAliceBobAliceBobstyled message
Source
@startuml
skinparam backgroundColor #EEF
Alice -> Bob: styled message
@enduml

Specify arrow color inline with -[#color].

AliceBobAliceBobAliceBobred message
Source
@startuml
Alice -[#red]-> Bob: red message
@enduml