Video failed to load

Markdown Mermaid Diagrams

1367 words
7 minutes
Markdown Mermaid Diagrams

A Complete Guide to Mermaid Diagrams in Markdown#

This article demonstrates how to create diagrams in Markdown with Mermaid, including flowcharts, sequence diagrams, ER diagrams, class diagrams, state diagrams, XY charts, Gantt charts, mind maps, and more.

Mermaid diagrams are powered by Merman. Firefly generates separate light and dark static SVGs during the Astro build, so no Mermaid rendering runtime is loaded in the browser. Visit Merman Playground to edit the syntax and preview the results interactively.

Flowchart Example#

Flowcharts are well suited to describing processes and algorithm steps.

是

否

选项 1

选项 2

选项 3

子过程详情

子步骤 1

子步骤 2

子步骤 3

开始

条件检查

处理步骤 1

处理步骤 2

另一个决策

结果 1

结果 2

结果 3

结束

是

否

选项 1

选项 2

选项 3

子过程详情

子步骤 1

子步骤 2

子步骤 3

开始

条件检查

处理步骤 1

处理步骤 2

另一个决策

结果 1

结果 2

结果 3

结束

Sequence Diagram Example#

Sequence diagrams show how objects interact over time.

数据库服务器网页应用用户数据库服务器网页应用用户alt[认证成功][认证失败]提交登录请求发送认证请求查询用户凭据返回用户数据返回认证结果显示欢迎页面请求用户数据获取用户偏好返回偏好设置返回用户数据加载个性化界面显示错误消息提示重新输入
数据库服务器网页应用用户数据库服务器网页应用用户alt[认证成功][认证失败]提交登录请求发送认证请求查询用户凭据返回用户数据返回认证结果显示欢迎页面请求用户数据获取用户偏好返回偏好设置返回用户数据加载个性化界面显示错误消息提示重新输入

ER Diagram Example#

ER diagrams, or entity-relationship diagrams, are useful for representing database structures.

writes

posts

has

belongs to

USER

int

id

PK

string

username

string

email

datetime

created_at

ARTICLE

int

id

PK

string

title

text

content

datetime

published

int

author_id

FK

COMMENT

int

id

PK

text

content

datetime

created_at

int

user_id

FK

int

article_id

FK

CATEGORY

int

id

PK

string

name

string

description

writes

posts

has

belongs to

USER

int

id

PK

string

username

string

email

datetime

created_at

ARTICLE

int

id

PK

string

title

text

content

datetime

published

int

author_id

FK

COMMENT

int

id

PK

text

content

datetime

created_at

int

user_id

FK

int

article_id

FK

CATEGORY

int

id

PK

string

name

string

description

Class Diagram Example#

Class diagrams show the static structure of a system, including classes, properties, methods, and their relationships.

写作

发表

拥有

属于

1

1

1

1

*

*

*

*

User

+String username

+String password

+String email

+Boolean active

+login()

+logout()

+updateProfile()

Article

+String title

+String content

+Date publishDate

+Boolean published

+publish()

+edit()

+delete()

Comment

+String content

+Date commentDate

+addComment()

+deleteComment()

Category

+String name

+String description

+addArticle()

+removeArticle()

写作

发表

拥有

属于

1

1

1

1

*

*

*

*

User

+String username

+String password

+String email

+Boolean active

+login()

+logout()

+updateProfile()

Article

+String title

+String content

+Date publishDate

+Boolean published

+publish()

+edit()

+delete()

Comment

+String content

+Date commentDate

+addComment()

+deleteComment()

Category

+String name

+String description

+addArticle()

+removeArticle()

State Diagram Example#

State diagrams show the sequence of states an object passes through during its lifecycle.

提交

拒绝

批准

发布

归档

撤回

草稿

审核中

已批准

已归档

已发布

临时隐藏

恢复

活跃

隐藏

提交

拒绝

批准

发布

归档

撤回

草稿

审核中

已批准

已归档

已发布

临时隐藏

恢复

活跃

隐藏

XY Chart Example#

XY charts are useful for displaying trends and comparing data.

月度访问量趋势1月2月3月4月5月6月5000450040003500300025002000150010005000访问量
月度访问量趋势1月2月3月4月5月6月5000450040003500300025002000150010005000访问量

Pie Chart Example#

Pie charts clearly show each part’s proportion of a whole.

45%30%15%10%内容类型占比技术文章 [45]项目记录 [30]生活随笔 [15]其他 [10]
45%30%15%10%内容类型占比技术文章 [45]项目记录 [30]生活随笔 [15]其他 [10]

Gantt Chart Example#

Gantt charts show project phases, task dependencies, and current progress on a timeline.

07/0107/0307/0507/0707/0907/1107/1307/1507/17需求整理 视觉设计 功能实现 内容迁移 构建检查 正式上线 准备开发发布博客版本发布计划
07/0107/0307/0507/0707/0907/1107/1307/1507/17需求整理 视觉设计 功能实现 内容迁移 构建检查 正式上线 准备开发发布博客版本发布计划

Mind Map Example#

Mind maps help organize topic hierarchies and knowledge structures.

Firefly

内容

技术文章

生活记录

体验

搜索

深色模式

图表

工程

Astro

Svelte

Merman

Firefly

内容

技术文章

生活记录

体验

搜索

深色模式

图表

工程

Astro

Svelte

Merman

Timeline Example#

Timelines present important project events by year or phase.

2024建立博客完成基础主题2025加入搜索与图库完善内容系统2026升级 Astro 7使用 Merman 渲染图表Firefly 演进时间线
2024建立博客完成基础主题2025加入搜索与图库完善内容系统2026升级 Astro 7使用 Merman 渲染图表Firefly 演进时间线

User Journey Example#

User journey diagrams describe user actions and experience scores at different stages.

读者
发现内容
发现内容
读者
打开首页
打开首页
读者
搜索主题
搜索主题
阅读文章
阅读文章
读者
浏览正文
浏览正文
读者
查看图表
查看图表
继续探索
继续探索
读者
查看相关文章
查看相关文章
读者
分享文章
分享文章
读者浏览文章的旅程
读者
发现内容
发现内容
读者
打开首页
打开首页
读者
搜索主题
搜索主题
阅读文章
阅读文章
读者
浏览正文
浏览正文
读者
查看图表
查看图表
继续探索
继续探索
读者
查看相关文章
查看相关文章
读者
分享文章
分享文章
读者浏览文章的旅程

Git Graph Example#

Git graphs clearly show branches, commits, and merge history.

mainfeatureinitadd-diagramspolish-themesmerge-featurerelease
mainfeatureinitadd-diagramspolish-themesmerge-featurerelease

Kanban Example#

Kanban boards show how tasks are distributed across workflow stages.

待办

进行中

已完成

整理需求

准备示例

接入 Merman

服务端渲染

亮暗主题

待办

进行中

已完成

整理需求

准备示例

接入 Merman

服务端渲染

亮暗主题

Sankey Diagram Example#

Sankey diagrams use link widths to represent the amount of flow between nodes.

Home 1650Post list 1200Search 450Post detail 1220Related posts 260External shares 180
Home 1650Post list 1200Search 450Post detail 1220Related posts 260External shares 180

Summary#

Mermaid is a powerful tool for creating many kinds of diagrams in Markdown. This article demonstrated flowcharts, sequence diagrams, ER and class diagrams, state diagrams, XY and pie charts, Gantt charts, mind maps, timelines, user journeys, Git graphs, Kanban boards, and Sankey diagrams. These diagrams help explain complex concepts, processes, and data structures more clearly.

To use Mermaid, specify the mermaid language on a fenced code block and describe your diagram with its concise text syntax. Diagrams are automatically rendered to SVG at build time, without loading client-side JavaScript.

Try more syntax in Merman Playground and then paste the diagram code into your article.

Support & Share

If this article helped you, please share or support!

Sponsor
Markdown Mermaid Diagrams
https://docs.bingyun.vip/en/posts/markdown-mermaid/
Author
BingYun
Published at
1970-01-03
Profile Image of the Author
BingYun
Hello, I'm BingYun
Tags
Table of Contents