📊

Mermaid Diagram Studio

Render Mermaid flowcharts, sequence, class, ER and gantt diagrams with SVG and PNG export.
Diagram 📂 Other 👤 ToolCMS 🏷️ v1.5.0 ⚙️ clipboard
Diagram · 图表编辑

写 Mermaid 语法,直接出可交付的 SVG

内置渲染器支持流程图、时序图、类图、ER 图与甘特图,不加载外部 CDN 与 mermaid.js。语法出错会指向具体行号,导出 SVG 或 PNG 可直接放进文档与 PPT。

图表写作规范

交付前逐条过
  • 一张图只表达一个主张:流程图讲步骤,时序图讲交互,状态图讲迁移,饼图讲占比,mindmap 讲结构。
  • 节点文字控制在 12 个汉字以内,超出会让连线交叉;本工具会自动折行,但折行不等于不拥挤。
  • 流程图优先自上而下,超过 12 个节点就拆成两张,阅读成本比一张大图低得多。
  • 时序图的参与者不超过 6 个,消息按时间顺序编号,异步消息单独标注。
  • 状态图必须给出终止态,否则评审时无法判断流程是否会卡死。
  • 饼图只用于“部分与整体”,且分片不超过 6 个;比较大小请用条形图。
  • 深色主题下不要用纯黑文字;导出 SVG 交给设计时把配色统一换成品牌色变量。
  • 嵌入文档前导出 SVG,缩放不糊;需要插进 PPT 或聊天窗口时再导出 2 倍 PNG。

图表源码

0 行

支持 flowchart / sequenceDiagram / classDiagram / erDiagram / gantt / stateDiagram / pie / mindmap / timeline 的常用子集。

语法诊断

0 条
  • 渲染后这里会列出无法识别的行,并给出行号。

结构分析

未分析

规模先于美观:节点太多、单个节点扇出过大、存在环或孤立节点,图就会难读。这里按当前源码给出深度、扇出、环与孤立节点。

指标结果说明
点“分析结构”后显示。

语法速查

六类图
类型首行要点
流程图graph TD节点用 A[文字],箭头 --> 或 ---,判断用 A{条件}
时序图sequenceDiagramparticipant 声明顺序即列顺序,消息 A->>B: 文本
类图classDiagramclass 名称 { +字段 } ,关系 <|-- 继承、*-- 组合
状态图stateDiagram-v2[*] 起点、[*] 终点,A --> B: 事件
饼图pie title 标题“分片名” : 数值,数值自动换算百分比
思维导图mindmap缩进表示层级,root((中心)) 作根节点

速查只列常用写法,完整语法以官方文档为准;本工具遇到无法识别的行会给出行号而不是静默跳过。

配色对比度与导出优化

未审计

按 WCAG 2.2 计算当前配色下文字与底色的对比度:正文 4.5:1(AA)、图形描边 3:1。对比度不足时,导出的图在投影仪与浅色打印上会糊成一片。

组合对比度AAAAA说明
点“审计对比度”后显示

压缩导出会去掉注释与标签间空白,图形与文字不变。

常见报错对照

诊断先看这里
  • 报“未知图形类型”:首行必须是小写关键字,graph / flowchart / sequenceDiagram 不能写错大小写。
  • 报“节点未闭合”:方括号、圆括号必须成对,中文全角括号不会被识别。
  • 连线全部指向同一节点:节点 ID 重复,后定义的会覆盖前一个,给每个节点换唯一 ID。
  • 时序图少了参与者:消息里出现的名字要先 participant 声明,否则顺序不可控。
  • 饼图数值为负或为零:占比无法计算,工具会跳过该分片并在诊断里提示行号。
  • 导出的 SVG 在 Word 里错位:Word 对 foreignObject 支持差,改用 PNG 或先转成图片再插入。

预览

100%
还没有图。左侧写入语法后点“渲染图表”。
节点—
连线—
尺寸—
渲染耗时—
最大深度—
健康评分—

支持的写法

按类型
图表支持的语法
flowchartgraph TD / flowchart LR;节点 A[文本]、B(圆角)、C{菱形}、D((圆))、E[(数据库)];连线 -->、---、-.->、==>、-->|文字|、-- 文字 -->;subgraph 分组
sequenceparticipant / actor、A->>B: 消息、A-->>B: 虚线、Note over A,B: 说明、Note right of A: 说明、loop/alt/opt/end 区块
classclass 名称 { +字段: 类型 \n +方法() }、<|-- 继承、--> 关联、..> 依赖、<|.. 实现,支持 : 标签
er实体 { string 名称 }、||--o{、||--||、}o--o{ 等基数写法,支持 : 标签
gantttitle、dateFormat YYYY-MM-DD、section 阶段、任务 :tag, 起始日期, 5d、milestone 里程碑

渲染器为自研实现,覆盖日常汇报与文档所需子集;mermaid.js 的冷门语法(如 mindmap、journey)不在支持范围内,遇到会给出行号提示而不是静默出错。

How to Use

📖 What it does

Architecture diagrams in documents are usually screenshots, so changing one word means redrawing. Mermaid describes diagrams as text, but the official renderer loads from a CDN and is unusable on intranets, air-gapped machines and pages that forbid external links.

This page ships its own renderer for the common subsets of flowchart, sequence, class, ER and gantt diagrams and produces native SVG that can be zoomed, themed and exported. A syntax mistake is reported with a line number instead of a blank canvas.

It is deliberately a subset: mindmap, journey and C4 are out of scope and are reported as unsupported. For the diagrams that appear in design docs, API references and handover notes, the coverage is enough.

✨ Features

  • Flowcharts with TD, LR, BT and RL directions, five node shapes, solid, dashed and thick edges with labels, and subgraph grouping.
  • Sequence diagrams with participants and actors, solid and dashed messages, notes over or beside participants, and loop, alt and opt frames.
  • Class diagrams with member blocks and inheritance, realisation, association and dependency relations, including labels on the relation.
  • ER diagrams with entity and attribute blocks, cardinality notations and relation labels.
  • Gantt charts with a title, sections, task start dates and durations, milestones and an automatically derived time axis.
  • A syntax check that parses without rendering and lists every unrecognised line with its number.
  • Preview zoom in, zoom out and fit to width, plus light, dark and print themes that swap a class on the SVG root.
  • Export SVG for documents and 2x PNG for slides and chat tools.
  • Keep the source next to the exported file, so the next edit starts from text rather than from a redrawn screenshot.
  • Everything renders locally with no font downloads, which keeps typography identical on an intranet machine and in an offline review.
  • State diagrams, pie charts and mind maps are rendered locally, and the template menu loads a working example for each.
  • Long node labels wrap by word and by character, and node width and height grow with the wrapped text instead of truncating to an ellipsis.
  • PNG export offers 1x to 4x scale and reports the exact pixel size produced.
  • A timeline renderer turns one line per period into a horizontal axis with event cards.
  • Label wrapping can be set to two, three, four or six lines and re-renders immediately, so long Chinese labels are no longer truncated.
  • PNG export gained a transparent background mode that removes the SVG background rectangle before rasterising, and Ctrl or Cmd plus Enter renders directly.
  • Exported SVG now carries title, desc and aria-label, so screen readers and embedded documents get the diagram semantics.
  • A Markdown export writes a fenced code block ready to paste into a README or document.
  • A timeline period now shows up to six events instead of four, with the height growing to match.
  • A source lint reports full-width brackets, tabs, unbalanced brackets, empty edge labels, duplicate node IDs and a missing diagram declaration, each with a line number.
  • A structure analysis lists nodes and edges, maximum depth, back edges, isolated nodes and the widest fan-out before you tune colours.
  • Exported SVG now embeds its palette, so it renders correctly outside this page, and a dark self-contained SVG is one click away.
  • A copy-source button makes pasting into a repository .md file trivial.
  • A WCAG 2.2 contrast audit measures text-on-fill and stroke-on-canvas ratios and flags anything below 4.5:1 or 3:1.
  • A high-contrast SVG export picks the text colour with the best contrast against the node fill, so projectors and printouts stay readable.
  • A minified export strips comments and inter-tag whitespace and reports the byte change without touching the drawing.
  • A 0-100 diagram health score combines node count, depth, cycles, isolated nodes and lint findings with concrete advice.

🚀 How to use it

  1. Pick a template type on the left and the page loads a runnable example.
  2. Edit the source as needed and switch the flowchart direction from the toolbar if the diagram gets too tall.
  3. Press Syntax check to confirm no line is unrecognised, then press Render.
  4. Inspect the preview, adjust zoom or fit to width, and switch themes to check how the export will look.
  5. Export SVG for a document or PNG for a slide, and keep the source next to the file so it can be edited later.

⚠️ Before you rely on it

  • The renderer is a hand-written subset; mermaid.js features such as mindmap, journey, C4 and requirement are not supported.
  • Node labels longer than 24 characters are truncated, so shorten the wording or split it into two connected nodes.
  • Class and ER layouts place at most two blocks per row and wrap automatically beyond that.
  • Gantt durations are measured in days; the d, h, m and w suffixes take the number only and no time zone conversion is applied.
  • Exported SVG colours come from CSS class names, so environments that ignore embedded styles should use PNG instead.
  • Very large diagrams become dense; beyond about 40 nodes, split the drawing rather than shrinking the text.

Related

⏫︎