Events and transitions
Label transitions with the command, event, or condition that moves the subject between states.
Lifecycle and transition modeling
Create a Mermaid state diagram online to describe lifecycle states, transitions, event or condition labels, choices, and terminal outcomes. Preview and export SVG or PNG.
Edit an order lifecycle with events, a choice, and terminal outcomes while checking that every transition remains understandable.
Build a Mermaid state diagram online
Changes render automatically in the preview.
State diagrams show what can happen next, which event causes a transition, and where an object or workflow can begin and end.
Label transitions with the command, event, or condition that moves the subject between states.
Represent labeled conditional outcomes, branching decisions, and explicit entry or completion points.
See the rendered result update as you edit and keep syntax feedback beside the source.
Work in a modern browser without installing Mermaid CLI, a desktop app, or an editor extension.
Move the current source into the full editor for AI generation, repair, sharing, and saved projects.
Define stable states first, then add only valid transitions and label the events or conditions that cause them.
Choose one subject whose lifecycle the diagram will explain.
List stable states rather than temporary implementation actions.
Add transitions and label them with meaningful events, commands, or condition text.
Mark initial, terminal, choice, and composite states where they change the lifecycle meaning.
Look for unreachable states and missing recovery paths before exporting.
A useful state diagram distinguishes durable states from actions and makes invalid or missing transitions visible during design review.
A state should describe a condition that remains true until an event occurs. Put actions and commands on transitions instead of turning each action into a state.
Labels such as submit, approve, timeout, or cancel explain why the lifecycle moves and expose missing business rules.
A choice node can show different next states with readable condition labels. Mermaid displays these labels but does not execute or validate the conditions.
Use a state diagram for the lifecycle of one subject. Use a flowchart for steps, decisions, and work moving through a process.
The example follows a draft through submission and review, then branches to approval or revision after rejection.
stateDiagram-v2
[*] --> Draft
Draft --> Submitted : submit
Submitted --> Review
state Review <<choice>>
Review --> Approved : valid
Review --> Rejected : invalid
Approved --> [*]
Rejected --> Draft : reviseCompare state modeling
Compare syntax, nested states, lifecycle notation, and the modeling depth available in each text-based diagram tool.
Read the state diagram comparison →Continue with the general editor, browse this release’s tool directory, or compare the diagram with a related modeling view.
Write Mermaid source, preview the result, and export SVG or PNG.
Open tool →Document messages between users, services, APIs, and databases over time.
Open tool →Model database entities, attributes, keys, and cardinality with Mermaid ER syntax.
Open tool →It is a browser tool for writing stateDiagram-v2 syntax, previewing lifecycle transitions, and exporting the result as SVG or PNG.
Use [*] as the source of a transition into the first state. Use [*] as a target to represent a terminal outcome.
Yes. Add a colon after the target state and write an event, command, or condition as display text. Mermaid does not execute or validate that label.
Yes. Declare a state with the <<choice>> stereotype and connect it to outcomes labeled with the relevant conditions.
Yes. Validate the live preview, then download SVG for scalable use or PNG for common image workflows.
A state diagram explains valid lifecycle transitions for one subject. A flowchart explains steps and decisions in a process.