merIDK / Diagram types / State diagram
Mermaid state diagram: example and syntax
State diagrams model something that moves between states, such as an order, a UI component or a network connection, and the events that cause each change.
Open this example in the editor
Example code
stateDiagram-v2
[*] --> Idle
Idle --> Running : start
state Running {
[*] --> Loading
Loading --> Ready
Ready --> Loading : reload
}
Running --> check
state check <<choice>>
check --> Done : success
check --> Failed : error
Failed --> Idle : retry
Done --> [*]
note right of Failed : Logged to Sentry
Result
stateDiagram-v2
[*] --> Idle
Idle --> Running : start
state Running {
[*] --> Loading
Loading --> Ready
Ready --> Loading : reload
}
Running --> check
state check <<choice>>
check --> Done : success
check --> Failed : error
Failed --> Idle : retry
Done --> [*]
note right of Failed : Logged to SentrySyntax quick reference
[*]is the start or end state.- Nest states with
state Name { ... }. - Branching:
state check <<choice>>; parallel paths:<<fork>>and<<join>>. - Notes:
note right of State : text.
How to use it
- Open the example in the editor, or paste your own Mermaid code.
- Edit the code on the left. The preview updates as you type, and errors point to the line.
- Export SVG or PNG, copy a Markdown block for GitHub or Notion, or copy a share link.