Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære 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

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 2

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

bookWriting Your First Mermaid Diagram

Sveip for å vise menyen

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

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 2
some-alt