Cheatsheet: PlantUML

Last updated 2026-07-20

Basics

Every diagram is wrapped in @startuml / @enduml

@startuml
Alice -> Bob : Hello
@enduml

Add a title and a single-line comment

@startuml
title My Sequence
' this is a comment
Alice -> Bob : Hi
@enduml

Sequence diagrams

Messages: -> solid, --> dashed (reply)

@startuml
Alice -> Bob : request
Bob --> Alice : response
@enduml

Declare participants and aliases

@startuml
actor User
participant "Web App" as Web
database "PostgreSQL" as DB
User -> Web : click
Web -> DB : query
@enduml

Activation / lifelines with activate & deactivate

@startuml
User -> API : POST /orders
activate API
API -> DB : insert
activate DB
DB --> API : ok
deactivate DB
API --> User : 201
deactivate API
@enduml

Notes (watch multi-line!)

Single-line note: text must stay on the same line after the colon

@startuml
Alice -> Bob : Hi
note over Alice, Bob : short note on one line
@enduml

Multi-line note: use a note ... end note block. A colon note that wraps to a second line is a syntax error.

@startuml
Alice -> Bob : Hi
note over Alice, Bob
  Asynchronous processing could be
  used for long-running tasks
  (e.g. payment)
end note
@enduml

Note position: left, right, or over one participant

@startuml
Alice -> Bob : Hi
note left of Alice : caller
note right of Bob : callee
@enduml

Class diagrams

Classes with fields and methods

@startuml
class User {
  +String email
  -int id
  +login()
}
@enduml

Relationships: inheritance, composition, association

@startuml
Animal <|-- Dog
Order *-- OrderLine
Customer "1" --> "*" Order : places
@enduml

Use case diagrams

Actors, use cases, and include

@startuml
left to right direction
actor Customer
Customer --> (Checkout)
(Checkout) ..> (Process payment) : include
@enduml

Activity diagrams

Start/stop, actions, and conditionals (new syntax)

@startuml
start
:Receive order;
if (In stock?) then (yes)
  :Ship order;
else (no)
  :Notify customer;
endif
stop
@enduml

Component diagrams

Components, packages, and links

@startuml
package "Backend" {
  [API Gateway]
  [User Service]
}
[API Gateway] --> [User Service]
@enduml

Styling

skinparam tweaks the look; !theme applies a built-in theme

@startuml
!theme plain
skinparam backgroundColor #FDFDFD
skinparam sequenceArrowThickness 2
Alice -> Bob : styled
@enduml

See also: