UML state machine diagram template
An order's life in five states and eight transitions: a trigger on every move between states, one guard where a condition decides, and an effect on the refund.
Notation: UML 2.5.1Diagram: State machine diagram
Open this template in Archyno
It opens in the editor as an editable model, not an image. No account needed: change it, then export to PNG, SVG, Mermaid or XMI. A free account, no card, saves it and adds the Sparx .qea export.
What is on this diagram
- Initial state
- The filled dot. One per state machine, and its arrow carries no event.
- Created
- Where every order starts. Rename the states to the stages of your own object.
- pay [amount = total]
- Trigger, then guard in brackets. The order moves only if the condition holds.
- Cancelled
- Reached from two states. Each way in is its own transition with its own trigger.
- cancel / refund()
- An effect after the slash. It runs on this transition only.
- Final state
- The ringed dot. Delivered and Cancelled both end here, without an event.
How to make it yours
- Rename the states to yours: one state per stage the object waits in, named as a state, not as an activity.
- Name each transition after the event that fires it, as a verb: 'ship', not 'Shipping'.
- Keep guards for real conditions. One guard is a rule; a guard on every transition is a flowchart.
- Write an effect after a slash when the move itself does something, like a refund.
- Check that every state has a way out, or ends in the final state.
Common questions
Does every transition need a trigger?
No. A transition without a trigger is a completion transition: it fires as soon as its source state has finished its work. The arrows into the final state here have none. Every other move in this template waits for an event, which is what makes the diagram worth drawing.
Where does the guard go on a transition?
In square brackets, after the trigger and before any effect: pay [amount = total] / receipt(). The transition fires only when the event arrives and the guard is true. If two transitions leave a state on the same event, their guards must never be true at the same time.
How many states should a state machine diagram have?
As many as the object has states it waits in, and no more. A state is a condition that lasts until an event arrives; a step that runs and ends on its own is an action, not a state. Most business objects need between four and ten.
What is the difference between a state machine and an activity diagram?
A state machine follows one thing and the states it can be in, and asks what may happen next. An activity diagram follows a process and its steps. If the question is whether a paid order can be cancelled, you are drawing a state machine.
Read the notation
How to read and draw a UML state machine diagram: states, transitions with trigger, guard and effect, entry and exit actions, composite states, and history pseudostates.
Worked UML state machine diagrams: an order lifecycle ending two different ways, a review workflow with a transition back to draft, and triggers versus guards on the way out of a state.
The symbols UML actually uses, across every diagram type: boxes, ellipses, diamonds, bars and 3D nodes, plus the six relationship lines and the arrowheads that tell them apart.