Whimsical LogoWhimsical LogoWhimsical Logo

Brand
Get all logo versions.
Download

State Diagram

A state diagram, or state machine diagram, shows the states an object moves through over its life and the events that trigger each transition. This template is a worked example, an order's lifecycle, running from Draft through Pending payment, Paid, Shipped, and Delivered, with Cancelled reachable along the way. Developers and analysts use it to model how something behaves as events change its state.

A UML state diagram of an order lifecycle: states from Draft to Delivered, with labeled transitions.

What's included

  • A worked order lifecycle. The states Draft, Pending payment, Paid, Shipped, Delivered, and Cancelled.
  • Labeled transitions. Each arrow names the event: submit, payment confirmed, payment failed, dispatch, delivered, cancel.
  • Initial and final nodes. A start point into Draft and an end point at Delivered.
  • A reachable cancel path. Cancelled is shown as an exit from several states, with a refund transition.

Why draw a state diagram?

  • Model behavior over time. See every state an object can be in, not just the happy path.
  • Catch impossible transitions. An illegal jump, like Paid back to Draft, is obvious on the diagram.
  • Design the edge cases. Cancellation, failure, and refunds get drawn, not discovered in production.
  • Spec it for developers. A state machine maps almost directly onto code.
  • Communicate the rules. Anyone can read which events move an order where.

How to use this template

  1. List the states. Name every state the object can be in, like Draft or Shipped.
  2. Mark the start. Add an initial node, a filled circle, pointing to the first state.
  3. Draw the transitions. Connect states with arrows in the direction the change happens.
  4. Label each event. Name what triggers each transition, like 'payment confirmed'.
  5. Add the exits. Show cancellation, failure, and other paths out of the normal flow.
  6. Mark the end. Close the lifecycle at a final node.

State diagram vs activity diagram

Both are UML behavior diagrams, but they model different things. A state diagram tracks one object through its states and the events that move it between them: the order is Draft, then Paid, then Shipped. An activity diagram models a process as a flow of actions and decisions, often across actors, closer to a flowchart. Use a state diagram when something has distinct states and rules for changing them; use an activity diagram to map how work flows from step to step.

Frequently asked questions

  • A state diagram, also called a state machine diagram, is a UML diagram that shows the states an object can be in and how it moves between them. Each state is a stage in the object's life; each transition is an arrow triggered by an event. It models behavior over time, answering what state something is in and what event moves it to the next one.

  • A state is a rounded rectangle with its name inside. A filled circle is the initial state, and a filled circle inside a ring is the final state. A solid arrow is a transition, labeled with the event that triggers it and any guard condition. A diamond is a choice point with one transition in and several out. Together these capture every state and the rules for changing it.

  • A state diagram tracks one object through its states and the events that move it between them: an order is Draft, then Paid, then Shipped. An activity diagram models a process as a flow of actions and decisions, often across actors, closer to a flowchart. Use a state diagram when something has distinct states and rules for changing them; use an activity diagram to map how work flows step by step.

  • List the states the object can be in, then add an initial node pointing to the first one. Connect states with arrows in the direction change happens, and label each arrow with the event that triggers it. Add the exits for cancellation, failure, and other off-path routes, and close the lifecycle at a final node. The result is a complete map of how the object behaves.

  • This template's board is one: an order's lifecycle. It starts at Draft, moves to Pending payment on submit, then to Paid on payment confirmed (or back on payment failed), then Shipped on dispatch and Delivered on delivery. Cancelled is reachable from several states, with a refund transition. A door (open, closed, locked) or a traffic light are other classic examples.