mermaid-js /mermaid
Generation of diagrams like flowcharts or sequence diagrams from text in a similar manner as markdown
★ 91,060⑂ 9,473👁 637⑃ 4,237● 3,951▤ 228◈ 451
91,060
stars
+12
9,473
forks
637
watchers
4,237
prs
3,951
issues
228
releases
451
discussions
README
Mermaid
通过解析类 Markdown 的文本语法来实现图表的创建和动态修改。
实时编辑器!
📖 文档 | 🚀 入门 | 🌐 CDN | 🙌 加入我们
English
尝试未来版本的实时编辑器预览: Develop | Next
:trophy: Mermaid 被提名并获得了 JS Open Source Awards (2019) 的 "The most exciting use of technology" 奖项!!!
感谢所有参与进来提交 PR,解答疑问的人们! 🙏
关于 Mermaid
--
Mermaid 是一个基于 JavaScript 的图表绘制工具,通过解析类 Markdown 的文本语法来实现图表的创建和动态修改。Mermaid 诞生的主要目的是让文档的更新能够及时跟上开发进度。
Doc-Rot 是 Mermaid 致力于解决的一个难题。
绘图和编写文档花费了开发者宝贵的开发时间,而且随着业务的变更,它很快就会过期。 但是如果缺少了图表或文档,对于生产力和团队新人的业务学习都会产生巨大的阻碍。
Mermaid 通过允许用户创建便于修改的图表来解决这一难题,它也可以作为生产脚本(或其他代码)的一部分。
Mermaid 甚至能让非程序员也能通过 Mermaid Live Editor 轻松创建详细的图表。
你可以访问 教程 来查看 Live Editor 的视频教程,也可以查看 Mermaid 的集成和使用 这个清单来检查你的文档工具是否已经集成了 Mermaid 支持。
如果想要查看关于 Mermaid 更详细的介绍及基础使用方式,可以查看 入门指引, 用法 和 教程.
--
示例
下面是一些可以使用 Mermaid 创建的图表示例。点击 语法 查看详情。
--
流程图 [文档 - live editor]
flowchart LR
A[Hard] --|Text| B(Round)
B -- C{Decision}
C --|One| D[Result 1]
C --|Two| E[Result 2]
mermaid
flowchart LR
A[Hard] --|Text| B(Round)
B -- C{Decision}
C --|One| D[Result 1]
C --|Two| E[Result 2]
时序图 [文档 - live editor]
sequenceDiagram
Alice-John: Hello John, how are you?
loop HealthCheck
John-John: Fight against hypochondria
end
Note right of John: Rational thoughts!
John--Alice: Great!
John-Bob: How about you?
Bob--John: Jolly good!
mermaid
sequenceDiagram
Alice-John: Hello John, how are you?
loop HealthCheck
John-John: Fight against hypochondria
end
Note right of John: Rational thoughts!
John--Alice: Great!
John-Bob: How about you?
Bob--John: Jolly good!
甘特图 [文档 - live editor]
gantt
section Section
Completed :done, des1, 2014-01-06,2014-01-08
Active :active, des2, 2014-01-07, 3d
Parallel 1 : des3, after des1, 1d
Parallel 2 : des4, after des1, 1d
Parallel 3 : des5, after des3, 1d
Parallel 4 : des6, after des4, 1d
mermaid
gantt
section Section
Completed :done, des1, 2014-01-06,2014-01-08
Active :active, des2, 2014-01-07, 3d
Parallel 1 : des3, after des1, 1d
Parallel 2 : des4, after des1, 1d
Parallel 3 : des5, after des3, 1d
Parallel 4 : des6, after des4, 1d
类图 [文档 - live editor]
classDiagram
Class01 Class01
Class09 -- C2 : Where am I?
Class09 -- C3
Class09 --| Class07
Class07 : equals()
Class07 : Object[] elementData
Class01 : size()
Class01 : int chimp
Class01 : int gorilla
class Class10 {
int id
size()
}
mermaid
classDiagram
Class01 Class01
Class09 -- C2 : Where am I?
Class09 -- C3
Class09 --| Class07
Class07 : equals()
Class07 : Object[] elementData
Class01 : size()
Class01 : int chimp
Class01 : int gorilla
class Class10 {
int id
size()
}
状态图 [docs - live editor]
stateDiagram-v2
[] -- Still
Still -- []
Still -- Moving
Moving -- Still
Moving -- Crash
Crash -- []
mermaid
stateDiagram-v2
[] -- Still
Still -- []
Still -- Moving
Moving -- Still
Moving -- Crash
Crash -- []
饼图 [文档 - live editor]
pie
"Top issues
#523Styling components of the sequence diagram103 comments · 2017-04-20#1462Component Diagram79 comments · 2020-06-10#2623BPMN support57 comments · 2022-01-13#1227New diagram type: network topology57 comments · 2020-01-28#2977Move the subgraph label to the bottom left corner51 comments · 2022-04-27#821Note in flowchart diagram51 comments · 2019-04-11#3208Backwards arrow direction46 comments · 2022-07-06#3989New Diagram Type: Tree Chart45 comments · 2023-01-13
Discussions
#8685Mermaid v13: going on a diet, and we want your input3 comments · 2026-11-04#8648Offer: priced triage packet for the 10 oldest triage bugs ($50)0 comments · 2026-10-31#8569flowchart: left directed arrow ⟵ (edges) is missing; is it possible to include, Thanks.0 comments · 2026-10-26#8468Mermaid Timeline Editor: In-browser editor with live preview and SVG export0 comments · 2026-10-18#8418SeqShow: step-by-step Mermaid sequence presentations with offline HTML export1 comments · 2026-10-10#8346Is anyone familiar with this type of diagram?0 comments · 2026-09-29#8325By default embedded fonts?1 comments · 2026-09-27#8317Significant layout change between 11.12.0 and 12.0.02 comments · 2026-09-25
Latest release
@mermaid-js/[email protected] @mermaid-js/[email protected] 2026-11-03Minor Changes
- 8164 592d0e4 Thanks @filipsajdak! - feat: add the open-arrow and hollow-circle edge markers, so a notation can tell two kinds of flow apart by whether the head is filled
- 8165 5c8aa5d Thanks @filipsajdak! - feat: add the BPMN element shapes - events, gateways, activities, data objects, data stores and text annotations - each reporting where a line meets what is drawn
- 8470 692d22a Thanks @openmindednewby! - feat: flowchart edges accept a step number (e1@{ step: 1 }); a dot travels the edges in step order and loops, hidden under prefers-reduced-motion
- 8478 56aa10相关报道 (6)
News & coverage (10)
Hacker NewsMermaid: Generation of diagrams like flowcharts or sequence diagrams from text▲ 255 · 107 comments · 2025-05-21Hacker NewsMermaid: Create complex diagrams using Markdown-inspired▲ 69 · 3 comments · 2022-02-15HackerNoonBuilding a Docs-as-Code Workflow With Markdown, Mermaid, and GitHub Actions2026-10-28GIGAZINEGitHub supports 'Mermaid', a library that automatically creates graphs from text2022-02-16I ProgrammerGitHub Supports Mermaid For Creating Diagrams2022-02-14BetaNewsGitHub adds native support for JavaScript-based diagramming tool, Mermaid2022-02-14GIGAZINEObsidian creator kepano has released 'Pele,' a lightweight open-source library that uses CSS for theme settings and renders Mermaid diagrams as SVGs.2026-10-20Visual Studio MagazineVS Code 1.121 Adds Remote Agents, Boosts Claude Code Functionality Again2026-05-20The GitHub BlogGitHub Copilot in Visual Studio — January update2026-02-04The GitHub BlogInclude diagrams in your Markdown files with Mermaid2022-02-14