State Diagram Generator for UML State Machines
Describe a system in plain English and get a state machine diagram with labeled states, transitions, events, and guards. Free to try.
Generate State Diagram
Free to try ·
What is a state diagram?
A state diagram — also called a UML state machine diagram — shows how a system moves between a finite set of states in response to events. Each rounded rectangle is a state the system can be in, and each arrow is a transition triggered by an event. It is the clearest way to model anything with distinct modes and rules for moving between them: an order that is Pending or Shipped, a connection that is Open or Closed, a device that is Idle or Running. This generator draws that behavior for you, with every state and transition placed and labeled.
What is a state machine (finite state machine)?
A state machine, or finite state machine (FSM), is a model of behavior with a finite number of states, exactly one of which is active at a time. The machine changes state only when a transition fires, and a transition is usually caused by an event. UML state machines add two refinements: a guard, a boolean condition that must be true for a transition to fire, and an action, behavior that runs during a transition or when a state is entered or exited. A state machine diagram is simply the picture of that model, which makes it easy to review with teammates and to check for missing or impossible transitions.
States, transitions, events, and initial and final states
- States: the distinct conditions a system can be in, drawn as rounded rectangles (for example, Idle, Processing, Shipped).
- Transitions: the arrows between states, showing a valid change from one state to another.
- Events: the trigger that fires a transition, written on the arrow (such as "payment received" or "timer expires").
- Guards and actions: a guard is a condition in brackets that must be true for the transition to fire; an action is work done during the transition.
- Initial state: a filled black circle marking where the machine starts.
- Final state: a circled dot marking where the machine ends, when the behavior has a clear completion.
Mealy vs. Moore state machines
- Moore machine: the output depends only on the current state. In a state diagram this is usually shown as an entry or "do" action inside the state, such as a traffic light turning the Green lamp on while in the Green state.
- Mealy machine: the output depends on the current state and the input event, so it is attached to the transition, for example "coin inserted / unlock turnstile". Mealy machines often need fewer states than an equivalent Moore machine.
- UML state diagrams can express both styles, because actions can be placed on transitions (Mealy-like) or inside states as entry and exit actions (Moore-like).
- To get either style from this generator, say in your description where the actions belong, for example "on entry to Green, turn on the green lamp" or "on coin inserted, unlock".
How to draw a state machine diagram in 4 steps
- List the states: write down every distinct mode the system can be in, and mark which one is the starting state.
- List the events: note everything that can happen to the system, such as user input, a timer expiring, or a message arriving.
- Connect them with transitions: for each state, decide which events are valid and which state each one leads to, adding a guard in brackets when a condition applies and an action after a slash when work is done.
- Check the result: make sure every state can be reached, that there is no state with no way out unless it is meant to be final, and that each event is handled or deliberately ignored in every state.
State diagram vs. state transition diagram vs. flowchart
A state diagram and a state transition diagram are often used interchangeably — both show states connected by event-driven transitions. The key difference from a flowchart is the focus: a flowchart traces the steps of a process from start to finish, while a state machine diagram captures the modes a system rests in and the events that move it between them. Use a state transition diagram whenever the question is "what state is it in now, and what can happen next?" rather than "what is the next step?"
When to use a state machine diagram
- Software design: model object lifecycles, UI screens, session and authentication flows, or any feature with clear modes and rules.
- Embedded and hardware systems: capture controllers such as traffic lights, elevators, vending machines, and motors, where behavior depends on the current state.
- Network protocols: document handshake and teardown sequences like TCP connection states, where each transition is an event-and-action pair.
- Business workflows: show an order, ticket, or approval moving through its statuses, including the conditions for each change.
- Specification and testing: a state diagram doubles as a checklist — every state and transition is a behavior to build and a path to test.
How to generate a state diagram from a description
- Describe your system in plain English: name the states it can be in and what causes it to move between them.
- Add the details that matter — events on each transition, guard conditions, and any entry or exit actions.
- Generate the diagram and the tool lays out the states and draws the transition arrows. Ask for the initial and final states in your description if you want them shown.
- Refine the wording or add states by editing your description, then export the finished state transition diagram to drop into docs, slides, or a spec.
State machine diagram examples you can generate
The order example above is a typical pattern; the same approach fits a user login flow with lockout and session timeout, a traffic light controller with timed transitions, an elevator, a protocol handshake, or a vending machine with a running total. Copy the closest sample prompt into the generator and change the state names, events, and guards to match your own system. For other UML views of the same system, such as its classes or message flow, see the UML class diagram and sequence diagram generators linked below.
Tips for a clear state transition diagram
Keep states to the genuinely distinct modes of the system — if two "states" always behave the same way, they are one state. Label every state-to-state transition with the event that triggers it (initial and completion transitions need none) so the diagram reads as cause and effect, and put any condition in a guard rather than inventing extra states. Use a single initial state, and add a final state only when the behavior truly ends. When a machine gets large, group related states into a composite (nested) state to keep the top level readable. Following these conventions keeps the diagram a true UML state machine that other engineers can pick up at a glance.
Frequently Asked Questions
Modeling more than behavior? Try the UML diagram generator for class diagrams and other UML views, or the sequence diagram generator for message flows between services.
