State Diagram Generator Guide

AI State Diagram Generator: Create UML State Machine Diagrams Free

flow-chart.io generates fully editable UML state machine diagrams from plain-language descriptions. Define your states, transitions, guard conditions, and composite states — and get a standards-conformant state diagram you can edit, share, and export immediately.

UML state diagram notation reference

A UML state machine diagram uses a small vocabulary of precisely defined symbols. Each element has a specific meaning that readers familiar with UML will interpret unambiguously.

ElementSymbolMeaning
Initial pseudostate● (filled black circle)The starting point of the state machine. Every state diagram has exactly one. A transition from the initial pseudostate leads to the first active state.
StateRounded rectangle with state nameA stable condition the object occupies. May include compartments for entry, exit, and do-activities written inside the box.
Final state◎ (circle inside a circle)Marks the end of the state machine lifecycle. An object that reaches the final state has completed its modelled behaviour.
TransitionDirected arrow between statesA response to an event that moves the object from source state to target state. Label syntax: trigger [guard] / action.
Guard condition[boolean expression] on a transitionAn optional condition in square brackets that must evaluate to true for the transition to fire. Allows one trigger to route to different target states based on data.
Entry / exit actionentry / action or exit / action inside stateBehaviour that runs automatically every time the state is entered or exited, regardless of which transition triggered the change.
Choice pseudostate◇ (diamond)A decision point where guards on outgoing transitions select the next state. Exactly one outgoing guard must be true; one is conventionally marked [else].

Real-world example: order lifecycle states

An e-commerce order moves through a predictable set of states from creation to completion. The following table shows the transitions, their triggers, and the guard conditions that control them.

From stateTo stateTriggerGuard / Action
● (initial)PendingorderPlaced— / assign order ID, send confirmation email
PendingProcessingpaymentConfirmed[payment.status == 'success'] / reserve inventory
PendingCancelledpaymentConfirmed[payment.status == 'failed'] / release hold, notify customer
ProcessingShippedfulfilmentComplete— / send tracking number
ShippedDelivereddeliveryConfirmed— / close order, trigger review request
ShippedCancelledreturnRequested[withinReturnWindow] / initiate return label
Delivered◎ (final)— (terminal state)
Cancelled◎ (final)— (terminal state)

Type this prompt into flow-chart.io to generate the above state diagram:

Order lifecycle state diagram: An order starts Pending after placement. It moves to Processing when payment is confirmed [payment.status == 'success'], with entry action to reserve inventory. It moves to Cancelled when payment fails. From Processing it moves to Shipped when fulfilment is complete, with action to send a tracking number. From Shipped it moves to Delivered when delivery is confirmed, or to Cancelled if a return is requested [withinReturnWindow]. Both Delivered and Cancelled are terminal states. Show as a UML state machine diagram.

Real-world example: user authentication states

An authentication session passes through a well-defined set of states from initial page load to token expiry. This diagram is useful for documenting session management in web applications.

From stateTo stateTriggerGuard / Action
● (initial)UnauthenticatedappLoaded— / check stored token
UnauthenticatedAuthenticatingloginSubmitted— / send credentials to auth service
AuthenticatingAuthenticatedauthSuccess— / store JWT, start session timer
AuthenticatingUnauthenticatedauthFailure[attempts < 5] / show error message
AuthenticatingLockedauthFailure[attempts >= 5] / lock account, notify security team
AuthenticatedSessionExpiredsessionTimerElapsed— / clear token, show expiry notice
AuthenticatedUnauthenticatedlogoutRequested— / clear token and session
SessionExpiredAuthenticatingloginSubmitted— / re-authenticate
SessionExpiredUnauthenticateddismissed

Real-world example: traffic light controller

A traffic light is a classic state machine with cyclic transitions and no terminal state. It demonstrates timed triggers and the use of entry actions for output control.

StateEntry actionTriggerNext state
Redentry / showRed, startTimer(60s)timerElapsedGreen
Greenentry / showGreen, startTimer(45s)timerElapsedYellow
Yellowentry / showYellow, startTimer(5s)timerElapsedRed

Composite states and nested state machines

A composite state contains a nested sub-state machine drawn inside its boundary. All sub-states inherit transitions defined on the composite state, which eliminates repetition across sibling states.

For example, consider an 'Authenticated' composite state containing sub-states 'Browsing', 'Checkout', and 'OrderReview'. Rather than adding a sessionTimeout transition to each sub-state individually, a single transition on the 'Authenticated' composite state routes all three sub-states to 'SessionExpired' when the session timer elapses.

Orthogonal composite states use dashed dividing lines to create concurrent regions. Each region runs its own sub-state machine independently. This models objects that track multiple simultaneous concerns — for example, a media player that tracks playback state (Playing / Paused / Stopped) independently from volume state (Normal / Muted) in parallel regions.

When generating composite states in flow-chart.io, describe the grouping in plain language: "Group Browsing, Checkout, and OrderReview inside an Authenticated composite state. The Authenticated state transitions to SessionExpired on sessionTimerElapsed from any sub-state."

State diagram best practices

How AI state diagram generation works in flow-chart.io

  1. Intent detection. The prompt is parsed to identify states, events, guards, and actions. Phrases like "moves to X when Y happens" map to transitions; "only if Z" maps to guards; "on entering, do A" maps to entry actions.
  2. Typed generation. Each element is a typed scene-graph object — not a freehand shape. States are rounded rectangle nodes; transitions are directed edge objects with trigger, guard, and action fields; pseudostates are specialised nodes. Every element conforms to UML 2.5.1 notation.
  3. Layout pass. States are arranged to minimise crossing transitions. The initial pseudostate is positioned at the top-left; the flow proceeds left-to-right and top-to-bottom. Composite states are rendered with their sub-states inside a larger boundary rectangle.

Because the output is a typed scene graph, every element is immediately editable — double-click a state to rename it, drag a transition endpoint to rewire it, or add a new state from the toolbar.

Frequently asked questions

What is a state diagram?
A state diagram (also called a UML state machine diagram or statechart) models the dynamic behaviour of a single object by showing all the discrete states it can occupy and the transitions that move it between those states in response to events. Each state represents a stable condition the object can be in — for example, an order can be Pending, Processing, Shipped, or Delivered. Transitions are labelled with the trigger event and, optionally, a guard condition in square brackets and an action after a slash. State diagrams are part of the UML 2.5.1 behavioural diagram family and are particularly effective for modelling protocol state machines, UI component lifecycles, and embedded system controllers.
What is the difference between a state and a transition in a state diagram?
A state is a condition or situation during the life of an object in which it satisfies some condition, performs some activity, or waits for some event. It is represented as a rounded rectangle labelled with the state name. A transition is a relationship between two states that indicates the object will move from the source state to the target state when a specified trigger event occurs. A transition is drawn as a directed arrow and is labelled with the syntax: trigger [guard] / action. The trigger is the event that causes the transition. The guard is an optional boolean condition in square brackets that must be true for the transition to fire. The action is an optional behaviour executed during the transition.
What are guard conditions in a UML state diagram?
A guard condition is a boolean expression placed in square brackets on a transition label — for example, [balance >= amount] or [retries < 3]. The transition only fires if the trigger event occurs AND the guard evaluates to true at that moment. Guards are evaluated after the trigger event is received and before the transition executes. They allow a single trigger event to lead to different target states depending on the system's current data, which is more concise than duplicating the entire state structure for each branch. In flow-chart.io, guard conditions are generated from natural-language descriptions: "transition to Locked only if failed attempts exceed 3" produces a transition labelled incorrectPin [failedAttempts > 3] / lockAccount.
What are entry and exit actions in a state diagram?
Entry and exit actions are behaviours that execute automatically whenever a state is entered or exited, regardless of which transition triggered the change. They are written inside the state rectangle as entry / actionName and exit / actionName. Entry actions are useful for initialisation work — starting a timer, loading data, or sending a notification. Exit actions handle cleanup — stopping a timer, saving state, or releasing a resource. Unlike transition actions, which execute only on a specific transition, entry and exit actions apply to all transitions into or out of the state, which reduces duplication and makes diagrams easier to maintain.
What are nested states and composite states in a UML state diagram?
A composite state is a state that contains one or more nested states (a sub-state machine) drawn inside it. The outer state is the composite state; the inner states are its sub-states. Composite states let you model hierarchical behaviour: all sub-states inherit the transitions defined on the composite state. For example, if any sub-state of an 'Authenticated' composite state receives a 'sessionTimeout' event, a single transition on the composite state can route to 'SessionExpired' without repeating that transition on every sub-state. Orthogonal (concurrent) composite states are divided into regions by dashed lines, each region running independently.
When should I use a state diagram instead of a flowchart?
Use a state diagram when you need to model the lifetime behaviour of a single object or system across many events over time — the emphasis is on what states the object is in and what triggers move it between those states. Use a flowchart when you need to model a single sequential process or algorithm — the emphasis is on the steps and decision points in a procedure. In practice: use a state diagram for a shopping cart (Idle → ItemsAdded → CheckingOut → OrderPlaced → Cancelled), a network connection (Closed → SYN_SENT → Established → Closed), or a vending machine controller. Use a flowchart for "how does the order fulfilment process work" or "what steps does a support agent follow to resolve a ticket".
What are best practices for drawing clear state diagrams?
Keep the number of states in one diagram to 12 or fewer — if you have more, use composite states to group related sub-states. Name states with a noun or adjective that describes the condition of the object, not the action that caused it: 'Authenticated' rather than 'Authenticate'. Label every transition with at least a trigger; add guards when a trigger can lead to more than one target state. Make every state reachable from the initial pseudostate and ensure every non-final state has at least one outgoing transition. Use composite states to avoid repeating the same transition on multiple sibling states. Always include an initial pseudostate (filled black circle) and, where the lifecycle ends, a final state (circle within a circle). Test your diagram by tracing at least two complete lifecycle paths — a happy path and an error path — to verify all states and transitions are covered.
Generate your first state diagram free.

40 AI credits/month on the free plan (~10 standard diagrams). No credit card required.

Generate a State Diagram Free →