Sequence Diagram
Sequence Diagram
Section titled “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.
Basic messages
Section titled “Basic messages”Use -> for a solid arrow and --> for a dashed arrow. Participants are inferred from the messages.
Source
@startuml
Alice -> Bob: hello
Bob --> Alice: hi
@enduml
Declaring participants
Section titled “Declaring participants”Declare participants explicitly to control their left-to-right order. Use participant, actor, or other keywords.
Source
@startuml
participant Alice
participant Bob
Alice -> Bob: Request
Bob --> Alice: Response
@enduml
Source
@startuml
actor User
User -> System: login
System --> User: welcome
@enduml
Self messages
Section titled “Self messages”A participant can send a message to itself.
Source
@startuml
Alice -> Alice: self message
@enduml
Add notes with the note keyword. Place them left of, right of, or over a participant.
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:
Source
@startuml
Alice -> Bob: hello
note over Alice, Bob: both
@enduml
Activation and deactivation
Section titled “Activation and deactivation”Use activate and deactivate to show lifeline activation.
Source
@startuml
Alice -> Bob: request
activate Bob
Bob --> Alice: response
deactivate Bob
@enduml
Grouping
Section titled “Grouping”Group messages with group/end, or use the alt/else/end and loop/end constructs.
Source
@startuml
group Authentication
Alice -> Bob: credentials
Bob --> Alice: token
end
@enduml
alt / else
Section titled “alt / else”Source
@startuml
alt success
Alice -> Bob: ok
else failure
Alice -> Bob: fail
end
@enduml
Source
@startuml
loop until done
Alice -> Bob: check
Bob --> Alice: not yet
end
@enduml
Dividers
Section titled “Dividers”Use == to insert a divider between groups of messages.
Source
@startuml
Alice -> Bob: step 1
== Phase 2 ==
Bob -> Alice: step 2
@enduml
Automatic numbering
Section titled “Automatic numbering”Use autonumber to automatically number messages.
Source
@startuml
autonumber
Alice -> Bob: first
Bob --> Alice: second
@enduml
Set a title with the title keyword.
Source
@startuml
title My Sequence
Alice -> Bob: hello
@enduml
Styling with skinparam
Section titled “Styling with skinparam”Customize appearance with skinparam. For example, set the background color.
Source
@startuml
skinparam backgroundColor #EEF
Alice -> Bob: styled message
@enduml
Colored messages
Section titled “Colored messages”Specify arrow color inline with -[#color].
Source
@startuml
Alice -[#red]-> Bob: red message
@enduml