All posts
FlowchartsState DiagramsDiagram TypesDecision Guide

Flowchart vs state diagram: picking the right tool

5 min readThe MermaidCreator team

Both flowcharts and state diagrams map out how things move from one condition to another—but they answer different questions. A flowchart asks "what do we do?" while a state diagram asks "what state is it in?" Picking the wrong one wastes time; picking the right one clarifies thinking instantly.

What flowcharts model

A flowchart shows a sequence of actions or decisions leading toward an outcome. Each box is a step; each arrow is a transition. The flow is imperative: "start here, do this, then that, decide, and loop back if needed."

Flowcharts shine for:

  • Processes — onboarding workflows, incident response, deployment steps
  • Procedures — how to handle a customer refund, reset a password, restock inventory
  • Decision trees — if A then B, else C, with multiple branches
  • Algorithms — breadth-first search, loan approval, recommendation ranking

Use a flowchart when the questions are: What steps happen? In what order? What decision points exist?

flowchart TD
    Start([Customer requests refund]) --> CheckDate{Purchase<br/>within 30 days?}
    CheckDate -->|Yes| CheckCondition{Item unused<br/>and sealed?}
    CheckCondition -->|Yes| Approve["✓ Approve refund"]
    CheckCondition -->|No| Partial["⚠ Partial refund"]
    CheckDate -->|No| Deny["✗ Deny (past window)"]
    Approve --> ProcessPayment["Process to original payment method"]
    Partial --> ProcessPayment
    Deny --> End([Case closed])
    ProcessPayment --> End

What state diagrams model

A state diagram shows a system transitioning between states in response to events or triggers. Each circle is a state; each arrow is a transition triggered by an event. The model is declarative: "when in state X, if event Y arrives, go to state Z."

State diagrams excel at:

  • System behavior — how an order moves through pending → confirmed → shipped → delivered
  • Protocol design — TCP connection states (LISTEN, ESTABLISHED, TIME_WAIT)
  • UI flows — a form moving between idle → loading → success → error states
  • Stateful logic — a traffic light cycling through red → yellow → green → red
  • Workflows — document approval: draft → submitted → reviewing → approved → archived

Use a state diagram when the questions are: What states exist? When do we transition? What triggers each transition?

stateDiagram-v2
    [*] --> Pending

    Pending --> Confirmed: Order placed
    Confirmed --> Processing: Payment OK
    Processing --> Shipped: Picked & packed
    Shipped --> Delivered: Arrived

    Pending --> Cancelled: Cancelled by user
    Confirmed --> Cancelled: Payment failed
    Processing --> Cancelled: Inventory issue

    Delivered --> [*]
    Cancelled --> [*]

Side-by-side comparison

AspectFlowchartState Diagram
ModelsActions and decisionsConditions and transitions
Boxes representSteps, processes, decisionsStates (noun: "the order is pending")
Arrows mean"Do this next""When X happens, go to Y"
TimeExplicit sequenceOnly relative to state changes
Loop intentRepeat a procedureCycle between states
Best for"How do we do X?""What state is X in?"
Typical audienceOperators, QA, trainersEngineers, designers, product

Real-world example: signup flow

As a flowchart — focusing on the steps we must perform:

flowchart TD
    Start([User visits signup]) --> EnterEmail["Enter email & password"]
    EnterEmail --> Submit["Submit form"]
    Submit --> Validate{Valid email<br/>format?}
    Validate -->|No| Error["Show error"]
    Error --> EnterEmail
    Validate -->|Yes| CreateAccount["Create account"]
    CreateAccount --> SendEmail["Send verification email"]
    SendEmail --> Done([Complete])

As a state diagram — focusing on the user's status through the process:

stateDiagram-v2
    [*] --> Unauthenticated

    Unauthenticated --> EmailInvalid: Invalid submission
    EmailInvalid --> Unauthenticated: User corrects
    Unauthenticated --> Unverified: Valid submission
    Unverified --> Unverified: Resend email
    Unverified --> Verified: Email clicked
    Verified --> [*]

Both tell a story, but the flowchart says "do these steps in order"; the state diagram says "the user progresses through these states as events occur."

When to use each

Pick a flowchart if:

  • You're documenting a process that humans or systems must follow (step-by-step)
  • You need to show loops, retries, or conditional branches
  • The primary audience is someone doing the work
  • Examples: bug triage, onboarding, CI/CD pipeline, customer service runbook

Pick a state diagram if:

  • You're designing or documenting a system's behavior (how it transitions)
  • Timing and state history matter more than the steps within a state
  • The primary audience is someone integrating with or monitoring the system
  • Examples: payment processing, network protocol, order status, authentication

Combining both approaches

Complex workflows often use both. For instance:

  • A state diagram shows the high-level order lifecycle (pending → confirmed → shipped → delivered)
  • A flowchart dives into what happens during the processing state (inventory check → payment → packing → label generation)

Together, they tell the full story: "here are the states the order lives in, and here's what we do inside each one."

FAQ

Can I turn a flowchart into a state diagram? Sometimes. If every flowchart step is atomic and leads to a single next state, yes. But most flowcharts have internal branching (if/else) and retries that don't map cleanly to states without adding extra state names. Use whichever model fits your mental model first.

Which is easier to test? State diagrams are often easier to test formally: given a state and an event, assert the next state. Flowcharts require testing every path and condition. For documentation, state diagrams are also easier to review — "is this transition possible?" — than flowcharts, which can sprawl.

Should I use a flowchart for a state machine? Not if you have a true state machine (a system with named states and triggered transitions). State diagrams are purpose-built for that model. Flowcharts will work but obscure the design.

Build your next flow in the MermaidCreator playground — start with a rough flowchart or state diagram, refine it visually, then export it to your docs.

Related posts