Tools / Editor

State Machine Diagram Builder

Map lifecycle states, events and transitions in a Mermaid state diagram. Add guards and actions, then preview and export the model.

Define allowed lifecycle changes

Describe the lifecycle of an order, job, or interface with a state machine diagram. States name stable conditions; transitions explain what causes a change. This keeps lifecycle rules separate from the sequence of implementation steps used to carry them out.

A worked example

Diagram source

stateDiagram-v2
  direction LR
  state "Draft" as Draft
  state "Review" as Review
  state "Published" as Published
  [*] --> Draft
  Draft --> Review : submit
  Review --> Published : approve [valid] / publish
  Published --> [*]
The example moves a document from Draft to Review and Published. Start and end markers identify lifecycle boundaries; the approval transition includes a guard and an action.

How to use this tool

  1. Create states with distinct IDs and clear labels. Use a parent state when a group shares a meaningful lifecycle context.
  2. Add transitions with a source, target, and event. Include guard and action text where it explains the rule.
  3. Trace normal, failure, and cancellation paths before exporting. Check whether every state has the intended way in and out.

What to check

DetailGuidance
Initial and final markersUse [*] at a lifecycle boundary. It is not an ordinary state with business data.
Guard conditionsDescribe the condition that permits a transition. The diagram does not execute or validate the condition.
Choice, fork, and joinUse these only when the model needs a decision or concurrent paths. Extra symbols can obscure a simple lifecycle.

Common questions

How is this different from a flowchart?

A state diagram focuses on what an object is allowed to become after an event. A flowchart focuses on steps in a process. Choose the former for lifecycle rules and the latter for procedural decisions.