When to use it
Use it to design a leave or other approval system, to write the status section of a requirements document, or to derive test cases. A flowchart says how people act; a state diagram says which states a request can be in and what moves it between them, which is what developers and testers need.
Make it yours
- Change approval levels to match your policy; each level adds a "Pending" state.
- The text after the colon is the trigger and can be the button label.
- Expense reports and purchase requests share the structure; replace the last two states with "Paid".
Mermaid code
stateDiagram-v2
[*] --> Draft : Create request
Draft --> PendingManager : Submit
Draft --> [*] : Delete
PendingManager --> Withdrawn : Employee withdraws
PendingManager --> Rejected : Manager rejects
PendingManager --> PendingDirector : Approved and over 3 days
PendingManager --> PendingHR : Approved and 3 days or fewer
PendingDirector --> Rejected : Reject
PendingDirector --> PendingHR : Approve
PendingHR --> Approved : HR confirms
Withdrawn --> Draft : Edit again
Rejected --> Draft : Revise and resubmit
Approved --> OnLeave : Start date reached
OnLeave --> Returned : Back at work
Returned --> [*]Ask an AI for one with this structure
Send the prompt below to ChatGPT or Claude, then paste the whole reply into the editor; the code inside is detected automatically.
Draw a leave request state diagram with Mermaid stateDiagram-v2 syntax. A new request starts as Draft and moves to PendingManager on submit. The manager may reject, the employee may withdraw, and on approval it goes to PendingDirector if over 3 days or to PendingHR otherwise. The director approves to PendingHR, and HR confirmation leads to Approved. Withdrawn and Rejected can return to Draft. Approved becomes OnLeave when the start date is reached, then Returned, then ends. Use state names without spaces and write the trigger after a colon on every transition. Output only the mermaid code block.
FAQ
- State diagram or flowchart?
Use a flowchart to show who does what in order, and a state diagram to show the states of a record and which actions change them.
- What is [*]?
It marks the start and the end. An arrow from it gives the initial state, and an arrow to it gives a final state.
- Why do the state names have no spaces?
State identifiers cannot contain spaces. To display spaces, declare a label, such as
state "Pending manager" as PendingManager.
More in this category
Updated 2026-11-11