Skip to content
All referenceBlock Elements

Markdown Mermaid Diagram

How to embed Mermaid diagrams in markdown for flowcharts, sequence diagrams, Gantt charts, and more. GitHub native support.

What is markdown mermaid diagram?

Mermaid is a JavaScript-based diagram tool that uses text syntax to generate flowcharts, sequence diagrams, Gantt charts, entity-relationship diagrams, and more. In markdown, a fenced code block with the mermaid language identifier tells the renderer to parse and render the Mermaid syntax as an SVG diagram.

Syntax

Flowchart

TD = top-down. Use LR for left-right. Nodes in [] are rectangles, {} are diamonds (decisions).

Result
(SVG flowchart)

Sequence diagram

->> is a solid arrow, -->> is a dashed arrow.

Result
(SVG sequence diagram)

Gantt chart

Gantt charts show project timelines with task dependencies.

Result
(SVG Gantt chart)

Platform support

PlatformSupportedNotes
GitHubYesNative rendering since 2022
GitLabYes
ObsidianYesNative rendering
NotionNo
DiscordNoRenders as code block
SlackNo

Common mistakes

Wrong
Using mermaid without the language identifier
Right
```mermaid (not just ```)

The block must be tagged with mermaid as the language. Without it, the content renders as a plain code block.

Tips for mermaid diagram

1Test in Mermaid Live Editor

Use mermaid.live to build and test diagrams before pasting into your markdown file. The editor gives instant visual feedback.

2Keep diagrams simple

Complex diagrams with many nodes become unreadable. Break large diagrams into multiple focused ones.

Frequently asked questions

Everything you need to know.

1

How do I add a diagram to a GitHub README?

Use a fenced code block with mermaid as the language: ```mermaid followed by your diagram syntax. GitHub has rendered Mermaid natively since 2022.

Related elements

Try it in the editor

Paste your markdown and see mermaid diagram rendered instantly with professional themes.