Flowcharts - Basic Syntax
Flowcharts are composed of nodes (geometric shapes) and edges (arrows or lines). The Mermaid code defines how nodes and edges are made and accommodates different arrow types, multi-directional arrows, and any linking to and from subgraphs.
If you are using the word "end" in a Flowchart node, capitalize the entire word or any of the letters (e.g., "End" or "END"), or apply this [workaround](https://github.com/mermaid-js/mermaid/issues/1444#issuecomment-639528897). Typing "end" in all lowercase letters will break the Flowchart.
If you are using the letter "o" or "x" as the first letter in a connecting Flowchart node, add a space before the letter or capitalize the letter (e.g., "dev--- ops", "dev---Ops").
Typing "A---oB" will create a [circle edge](#circle-edge-example).
Typing "A---xB" will create a [cross edge](#cross-edge-example).
A node (default)
---
title: Node
---
flowchart LR
id
The id is what is displayed in the box.
Instead of `flowchart` one can also use `graph`.
A node with text
It is also possible to set text in the box that differs from the id. If this is done several times, it is the last text found for the node that will be used. Also if you define edges for the node later on, you can omit text definitions. The one previously defined will be used when rendering the box.
---
title: Node with text
---
flowchart LR
id1[This is the text in the box]
Unicode text
Use " to enclose the unicode text.
flowchart LR
id["This ❤ Unicode"]
Markdown formatting
Use double quotes and backticks "` text `" to enclose the markdown text.
---
config:
flowchart:
htmlLabels: false
---
flowchart LR
markdown["`This **is** _Markdown_`"]
newLines["`Line1
Line 2
Line 3`"]
markdown --> newLines
Direction
This statement declares the direction of the Flowchart.
This declares the flowchart is oriented from top to bottom (TD or TB).
flowchart TD
Start --> Stop
This declares the flowchart is oriented from left to right (LR).
flowchart LR
Start --> Stop
Possible FlowChart orientations are:
- TB - Top to bottom
- TD - Top-down/ same as top to bottom
- BT - Bottom to top
- RL - Right to left
- LR - Left to right
Node shapes
A node with round edges
flowchart LR
id1(This is the text in the box)
A stadium-shaped node
flowchart LR
id1([This is the text in the box])
A node in a subroutine shape
flowchart LR
id1[[This is the text in the box]]
A node in a cylindrical shape
flowchart LR
id1[(Database)]
A node in the form of a circle
flowchart LR
id1((This is the text in the circle))
A node in an asymmetric shape
flowchart LR
id1>This is the text in the box]
Currently only the shape above is possible and not its mirror. This might change with future releases.
A node (rhombus)
flowchart LR
id1{This is the text in the box}
A hexagon node
flowchart LR
id1{{This is the text in the box}}
Parallelogram
flowchart TD
id1[/This is the text in the box/]
Parallelogram alt
flowchart TD
id1[\This is the text in the box\]
Trapezoid
flowchart TD
A[/Christmas\]
Trapezoid alt
flowchart TD
B[\Go shopping/]
Double circle
flowchart TD
id1(((This is the text in the circle)))
Expanded Node Shapes in Mermaid Flowcharts (v11.3.0+)
Mermaid introduces 30 new shapes to enhance the flexibility and precision of flowchart creation. These new shapes provide more options to represent processes, decisions, events, data storage visually, and other elements within your flowcharts, improving clarity and semantic meaning.
New Syntax for Shape Definition
Mermaid now supports a general syntax for defining shape types to accommodate the growing number of shapes. This syntax allows you to assign specific shapes to nodes using a clear and flexible format:
A@{ shape: rect }
This syntax creates a node A as a rectangle. It renders in the same way as A["A"], or A.
Complete List of New Shapes
Below is a comprehensive list of the newly introduced shapes and their corresponding semantic meanings, short names, and aliases:
<!--@include: virtual:shapesTable -->Example Flowchart with New Shapes
Here’s an example flowchart that utilizes some of the newly introduced shapes:
flowchart RL
A@{ shape: manual-file, label: "File Handling"}
B@{ shape: manual-input, label: "User Input"}
C@{ shape: docs, label: "Multiple Documents"}
D@{ shape: procs, label: "Process Automation"}
E@{ shape: paper-tape, label: "Paper Records"}
Process
flowchart TD
A@{ shape: rect, label: "This is a process" }
Event
flowchart TD
A@{ shape: rounded, label: "This is an event" }
Terminal Point (Stadium)
flowchart TD
A@{ shape: stadium, label: "Terminal point" }
Subprocess
flowchart TD
A@{ shape: subproc, label: "This is a subprocess" }
Database (Cylinder)
flowchart TD
A@{ shape: cyl, label: "Database" }
Start (Circle)
flowchart TD
A@{ shape: circle, label: "Start" }
Odd
flowchart TD
A@{ shape: odd, label: "Odd shape" }
Decision (Diamond)
flowchart TD
A@{ shape: diamond, label: "Decision" }
Prepare Conditional (Hexagon)
flowchart TD
A@{ shape: hex, label: "Prepare conditional" }
Data Input/Output (Lean Right)
flowchart TD
A@{ shape: lean-r, label: "Input/Output" }
Data Input/Output (Lean Left)
flowchart TD
A@{ shape: lean-l, label: "Output/Input" }
Priority Action (Trapezoid Base Bottom)
flowchart TD
A@{ shape: trap-b, label: "Priority action" }
Manual Operation (Trapezoid Base Top)
flowchart TD
A@{ shape: trap-t, label: "Manual operation" }
Stop (Double Circle)
flowchart TD
A@{ shape: dbl-circ, label: "Stop" }
Text Block
flowchart TD
A@{ shape: text, label: "This is a text block" }
Card (Notched Rectangle)
flowchart TD
A@{ shape: notch-rect, label: "Card" }
Lined/Shaded Process
flowchart TD
A@{ shape: lin-rect, label: "Lined process" }
Start (Small Circle)
flowchart TD
A@{ shape: sm-circ, label: "Small start" }
Stop (Framed Circle)
flowchart TD
A@{ shape: framed-circle, label: "Stop" }
Fork/Join (Long Rectangle)
flowchart TD
A@{ shape: fork, label: "Fork or Join" }
Collate (Hourglass)
flowchart TD
A@{ shape: hourglass, label: "Collate" }
Comment (Curly Brace)
flowchart TD
A@{ shape: comment, label: "Comment" }
Comment Right (Curly Brace Right)
flowchart TD
A@{ shape: brace-r, label: "Comment" }
Comment with braces on both sides
flowchart TD
A@{ shape: braces, label: "Comment" }
Com Link (Lightning Bolt)
flowchart TD
A@{ shape: bolt, label: "Communication link" }
Document
flowchart TD
A@{ shape: doc,