Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära Writing Your First Mermaid Diagram | Getting Started with Mermaid.js
Mermaid.js Diagrams with JavaScript

bookWriting Your First Mermaid Diagram

Mermaid.js lets you create diagrams using a simple and readable syntax. To write Mermaid diagrams, you use a code block that signals to Mermaid what kind of diagram you want to create. This code block starts with three backticks followed by the word mermaid. Everything you write inside this block will be interpreted as Mermaid syntax. The basic structure for a flowchart in Mermaid uses the flowchart keyword, followed by the direction of the flow, such as TD for top-down or LR for left-to-right. Inside the code block, you define nodes (steps or actions) and connect them with arrows to show the flow of your process.

index.html

index.html

copy

Let's break down the flowchart syntax in the example above. The first line, flowchart TD, tells Mermaid to create a flowchart with a top-down layout. Each node is defined by a letter and a label in square brackets, such as A[Start]. Nodes are connected using arrows—-->—showing the direction from one step to the next. For decisions, curly braces are used for the label, like B{Is it sunny?}, and different outcomes are connected with labeled arrows, such as B -- Yes --> C[Go outside] and B -- No --> D[Stay inside]. All paths eventually lead to the final node E[Have fun!], demonstrating how to build a simple decision flow using Mermaid syntax.

question mark

What is the correct way to start a Mermaid flowchart code block?

Select the correct answer

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 1. Kapitel 2

Fråga AI

expand

Fråga AI

ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

bookWriting Your First Mermaid Diagram

Svep för att visa menyn

Mermaid.js lets you create diagrams using a simple and readable syntax. To write Mermaid diagrams, you use a code block that signals to Mermaid what kind of diagram you want to create. This code block starts with three backticks followed by the word mermaid. Everything you write inside this block will be interpreted as Mermaid syntax. The basic structure for a flowchart in Mermaid uses the flowchart keyword, followed by the direction of the flow, such as TD for top-down or LR for left-to-right. Inside the code block, you define nodes (steps or actions) and connect them with arrows to show the flow of your process.

index.html

index.html

copy

Let's break down the flowchart syntax in the example above. The first line, flowchart TD, tells Mermaid to create a flowchart with a top-down layout. Each node is defined by a letter and a label in square brackets, such as A[Start]. Nodes are connected using arrows—-->—showing the direction from one step to the next. For decisions, curly braces are used for the label, like B{Is it sunny?}, and different outcomes are connected with labeled arrows, such as B -- Yes --> C[Go outside] and B -- No --> D[Stay inside]. All paths eventually lead to the final node E[Have fun!], demonstrating how to build a simple decision flow using Mermaid syntax.

question mark

What is the correct way to start a Mermaid flowchart code block?

Select the correct answer

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 1. Kapitel 2
some-alt