Flowcharts turn a process into nodes and arrows: steps, decisions, and the path between them. Edit the diagram above, or copy one of the examples below.
flowchart TD
A([Open cart]) --> B{Signed in?}
B -->|No| C[Sign in]
C --> B
B -->|Yes| D{Payment accepted?}
D -->|No| E[Show the error]
E --> D
D -->|Yes| F[Create the order]
F --> G([Confirmation])
Service boundaries with subgraphs
A left-to-right view of a browser, an API, and a database. Subgraphs group nodes that belong to the same system.
flowchart TB
Start([Git push]) --> Lint[Lint and typecheck]
Lint --> Test[Run tests]
Test --> Build[Production build]
Build --> Target{Branch is main?}
Target -->|Yes| Deploy[Deploy]
Target -->|No| Preview[Publish a preview]
What is a Flowchart?
A Mermaid flowchart is a directed graph. Each node is a step or a decision, and each arrow is the path to the next step. Start the diagram with a direction — TD for top-down, LR for left-to-right — then declare nodes by writing an id and a shape. Rectangles hold actions, diamonds hold yes/no questions, and rounded nodes mark the start or end. Use a flowchart when the reader needs to follow one process from a trigger to an outcome, including the branches that depend on a condition.
When to use it
Use a flowchart for approval paths, onboarding, incident response, and algorithm logic. Switch to a sequence diagram when the story is messages between services over time, and to a state diagram when the important fact is which mode an object is in rather than the next step.
•Process documentation - Map business workflows and procedures
•Decision trees - Visualize if/then logic and branching paths
•System architecture - Show data flow between components
•Algorithm design - Plan code logic before implementation
•User journeys - Document how users navigate through an app
Syntax Quick Reference
Element
Syntax
Description
Rectangle
[Text]
Process step or action
Rounded
(Text)
Start or end point
Diamond
{Text}
Decision point
Circle
((Text))
Connector or reference
Arrow
-->
Flow direction
Arrow with label
-->|Label|
Labeled connection
Syntax tips
•Declare the direction on the first line: flowchart TD, LR, BT, or RL. TD is the usual choice for a process; LR fits architecture sketches.
•Node ids should be single words. Put the visible label in brackets: login[Sign in]. Spaces in the id are a syntax error.
•Put arrow text between pipes: A -->|Yes| B. The label sits on the link, not inside the next node.
•Wrap a group in subgraph Name ... end. A subgraph can link to a node outside the group.
•style A fill:#1f6feb,color:#fff colors one node. classDef and class reuse the same colors on several nodes.
Common mistakes
Writing graph TD or forgetting the direction keyword.
Start with flowchart TD or flowchart LR. The older graph keyword still renders, but flowchart enables more link styles.
Using end, subgraph, or graph as a node id.
Those words are reserved. Name the node something else and set the label explicitly: finish[End].
Drawing a decision as a rectangle and hiding the branch in the node text.
Use a diamond, {Paid?}, and put Yes and No on the outgoing arrows.
Export Options
Flowcharts are usually read in docs and slide decks. SVG stays sharp when the page is zoomed; PNG is the safer drop-in for Google Slides and Keynote. Free PNG files include a watermark.
Use curly braces for the decision node and put each answer on its own arrow. Example: B{Signed in?} then B -->|Yes| C and B -->|No| D. The diamond is the question; the arrow labels are the branches.
TD lays the diagram out from top to bottom, which suits a process you read as a list of steps. LR lays it out from left to right, which suits a pipeline or a handoff between systems. The nodes and arrows stay the same; only the direction keyword changes.
Wrap the nodes in a subgraph. Write subgraph Client, list the nodes, then close it with end. You can still draw arrows from a node inside the subgraph to a node outside it.
The usual cause is a node id with a space, a reserved word such as end, or an arrow label missing its pipes. Keep ids as single tokens, write the label as A[Visible text], and write links as A -->|label| B.
Use SVG for docs and the web, because the shapes stay sharp at any size. Use PNG for slides. Free PNG downloads include a watermark; Pro removes the watermark and raises the export scale. PDF is in the same export dialog.
Ready to create your own flowchart?
Open the editor with this example pre-loaded and start customizing.