Flowchart TD online
flowchart TD is the line Mermaid’s current documentation uses to start a flowchart and lay it out from top to bottom.
If a README still says graph TD, leave it. Both keywords draw the same top-down layout. Reach for flowchart TD when you are writing a new diagram and want the keyword the docs use now.
This page is the short version: the direction token, the node shapes, and one example you can edit in the free online editor. Sequence diagrams, class diagrams and the other types stay on the syntax guide.
Editable example
Change any label in the text box, then open the live editor to see the preview and export. The link below opens this flowchart TD example even if you do not change the box.
flowchart TD
A[Receive request] --> B{Complete?}
B -->|Yes| C[Draw flowchart TD]
B -->|No| D[Add the missing step]
D --> B
C --> E[Share a link]The link opens the example printed above. If you change the text box, the button sends your edited copy to the editor instead.
Edit this flowchart TD example in the free Mermaid editorSyntax cheat sheet
flowchart TD uses the same node and arrow syntax as graph TD. Only the first keyword differs.
| Syntax | Meaning |
|---|---|
graph TD | Start a top-down flowchart. graph is the older keyword, and it still renders. |
flowchart TD | Start a top-down flowchart with the keyword used in the current Mermaid documentation. |
TD / TB / BT / LR / RL | Direction after the keyword: top-down, top-to-bottom, bottom-to-top, left-to-right, or right-to-left. |
A[Text] | A rectangular step. |
B{Text} | A decision diamond. |
C(Text) | A rounded node. |
A --> B | An arrow from A to B. |
A -->|Yes| B | An arrow with a label on it. |
A["Text (note)"] | Put quotes around a label that contains parentheses or other punctuation. |
flowchart TD and graph TD
flowchart is the keyword in the current Mermaid documentation. graph is the older alias. With TD after either keyword, Mermaid draws a top-down flowchart and the layout matches.
You do not have to migrate old graph TD diagrams. Change the keyword only when you want new code to follow the current docs. For a sideways process, write flowchart LR instead of flowchart TD.
| Comparison | graph TD | flowchart TD |
|---|---|---|
| Keyword | graph, an older alias that still renders | flowchart, the keyword in the current docs |
| Direction | TD, top to bottom | TD, top to bottom |
| Layout | Top-down flowchart | The same top-down flowchart |
| When to use it | Keep it on diagrams you already have | Prefer it when you write a new diagram |
How to write a flowchart TD diagram
Create a top-down Mermaid flowchart with flowchart TD, check the live preview, and export or share it.
- Declare flowchart TD. Put flowchart TD on the first line so Mermaid treats the rest of the file as a top-down flowchart.
- Describe each step. Add rectangle steps with square brackets, decisions with curly braces, and arrows with -->. Label a branch with -->|Yes| or -->|No|.
- Open the live preview and export. Open the example in the editor. The preview updates as you edit. Export PNG, SVG or PDF, or share a link that carries the code without uploading it.
FAQ
What does flowchart TD mean?
flowchart starts a Mermaid flowchart, and TD means top-down. It sets the overall layout direction; branches and loops can still point in other directions. Use LR, RL or BT for a different overall direction.
Should I replace graph TD with flowchart TD?
Only if you want the keyword from the current Mermaid documentation. graph TD still renders the same top-down layout, so existing diagrams do not need a rewrite.
Which directions can a flowchart use?
TD and TB are top to bottom, BT is bottom to top, LR is left to right, and RL is right to left. The example on this page uses TD.
Do I need an account to draw a flowchart TD diagram here?
No. The editor, the live preview, PNG, SVG and PDF export, and share links are free and do not ask you to sign up. The diagram renders in your browser.
Related guides
Stay on flowchart TD, or open the alias, the broader flowchart page, and the editor.
- graph TD syntax, the older alias that still works
- Mermaid flowchart examples beyond the first line
- preview flowchart TD in the Mermaid live editor
- flowchart tutorial: directions, shapes and subgraphs
- flowchart syntax guide
- FAQ answer on graph TD versus flowchart TD
- how to export PNG, SVG or PDF
- free Mermaid online editor