State diagram (PlantUML)

PlantUML state diagrams support composite states, which is what you need once a state has its own internal machine.


#What this example shows

  • A composite state containing its own sub-states.

  • Guards in square brackets on transitions.

  • Entry actions, written inside the state.


#A worked example

Open it, edit it, or copy the source below.

State diagram (PlantUML)

The source, which you can paste into a new diagram and edit:

@startuml
[*] --> Draft

Draft --> Submitted : submit
Submitted --> InReview : picked up

state InReview {
  [*] --> TechnicalReview
  TechnicalReview --> LegalReview : technical approved
  LegalReview --> [*] : legal approved
  TechnicalReview --> [*] : rejected
}

InReview --> Approved : all reviews passed
InReview --> Draft : changes requested
Approved --> Published : publish [scheduled date reached]
Published --> Archived : archive [older than 2 years]
Archived --> [*]

Draft : entry / notify author
Published : entry / invalidate cache

note right of InReview
  Reviewers are reminded
  every 48 hours.
end note
@enduml

#Making it your own

  • Guards go in square brackets after the event, and they are where the real rules live.

  • Composite states keep large machines readable; use them before splitting the diagram.

  • Entry and exit actions belong on the state, not on every incoming arrow.



Verbose, stable, and it draws almost everything.