Cheatsheet: PlantUML

Last updated 2026-09-24

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

Grouping: alt/else, loop, and opt frames

@startuml
Client -> Server : request
alt success
  Server --> Client : 200 OK
else failure
  Server --> Client : 500 error
end

loop every 30s
  Client -> Server : heartbeat
end

opt cache is stale
  Server -> Cache : refresh
end
@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

Rendering (CLI and local setup)

Render a .puml file to PNG or SVG with the jar

java -jar plantuml.jar diagram.puml
java -jar plantuml.jar -tsvg diagram.puml

Render every .puml file in a directory recursively

java -jar plantuml.jar -tsvg "src/**/*.puml"

Some diagram types (e.g. component diagrams) shell out to Graphviz's dot -- make sure it's on your PATH

dot -V

Styling

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

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

FAQ