FlowDiagram
UML: sequence, class & stateMermaid

Vending machine state machine template

Shows a snack vending machine accepting coins or card, selecting a product, dispensing, giving change and handling sold-out and refunds; a common state machine teaching example. This state machine has 9 states and 17 transitions, triggered by events such as “coin inserted”, “card tapped”, “more coins”.

Open in the editor →
  • Free — no account, no trial, no watermark
  • Fully editable shapes and connectors, not a screenshot
  • Export PNG, SVG or PDF, or share it as a link
  • Private: the diagram never leaves your browser

States in this state machine

  • Idle
  • Collecting Money
  • Card Authorising
  • Product Selected
  • Refunding
  • stock
  • Dispensing
  • Giving Change
  • Out Of Service

How to use this state diagram template

  1. Click Open in the editor. The state diagram opens on a new page in FlowDiagram — nothing is uploaded and there is no sign-up.
  2. Rename, add or delete shapes and drag them where you want; connectors stay attached as things move.
  3. Drop in vendor logos from the library — 1,160 of them, including every AWS, Azure and Google Cloud service icon — or restyle it with the colour and theme controls.
  4. Prefer text? Edit the Mermaid source below and paste it in through ☰ → Import diagram (see the Mermaid editor); it imports as an editable diagram.
  5. Export to PNG, SVG or PDF, or press Ctrl+L for a link that carries the whole diagram.

Mermaid source

The whole template is the text below. Paste it into FlowDiagram, keep it in Git next to the code it describes, or hand it to an AI assistant to extend.

stateDiagram-v2
  [*] --> Idle
  Idle --> CollectingMoney : coin inserted
  Idle --> CardAuthorising : card tapped
  CollectingMoney --> CollectingMoney : more coins
  CollectingMoney --> ProductSelected : item chosen
  CollectingMoney --> Refunding : cancel pressed
  CardAuthorising --> ProductSelected : card approved
  CardAuthorising --> Idle : card declined
  state stock <<choice>>
  ProductSelected --> stock
  stock --> Dispensing : in stock and paid
  stock --> Refunding : sold out
  Dispensing --> GivingChange : item dropped
  GivingChange --> Idle : change returned
  Refunding --> Idle : money returned
  Idle --> OutOfService : door opened
  OutOfService --> Idle : restocked
  OutOfService --> [*]

Related: Mermaid editor · All uml: sequence, class & state templates · All 521 templates