Mermaid Visualizer
Overview
Convert text content into clean, professional Mermaid diagrams optimized for presentations and documentation. Automatically handles common syntax pitfalls (list syntax conflicts, subgraph naming, spacing issues) to ensure diagrams render correctly in Obsidian, GitHub, and other Mermaid-compatible platforms.
Quick Start
When creating a Mermaid diagram:
- 1. Analyze the content - Identify key concepts, relationships, and flow
- Choose diagram type - Select the most appropriate visualization (see Diagram Types below)
- Select configuration - Determine layout, detail level, and styling
- Generate diagram - Create syntactically correct Mermaid code
- Output in markdown - Wrap in proper code fence with optional explanation
Default assumptions:
- - Vertical layout (TB) unless horizontal requested
- Medium detail level (balanced between simplicity and information)
- Professional color scheme with semantic colors
- Obsidian/GitHub compatible syntax
Diagram Types
1. Process Flow (graph TB/LR)
Best for: Workflows, decision trees, sequential processes, AI agent architectures
Use when: Content describes steps, stages, or a sequence of actions
Key features:
- - Swimlanes via subgraph for grouping related steps
- Arrow labels for transitions
- Feedback loops and branches
- Color-coded stages
Configuration options:
- -
layout: "vertical" (TB), "horizontal" (LR) - INLINECODE1 : "simple" (core steps only), "standard" (with descriptions), "detailed" (with annotations)
- INLINECODE2 : "minimal", "professional", "colorful"
2. Circular Flow (graph TD with circular layout)
Best for: Cyclic processes, continuous improvement loops, agent feedback systems
Use when: Content emphasizes iteration, feedback, or circular relationships
Key features:
- - Central hub with radiating elements
- Curved feedback arrows
- Clear cycle indicators
3. Comparison Diagram (graph TB with parallel paths)
Best for: Before/after comparisons, A vs B analysis, traditional vs modern systems
Use when: Content contrasts two or more approaches or systems
Key features:
- - Side-by-side layout
- Central comparison node
- Clear differentiation via color/style
4. Mindmap
Best for: Hierarchical concepts, knowledge organization, topic breakdowns
Use when: Content is hierarchical with clear parent-child relationships
Key features:
- - Radial tree structure
- Multiple levels of nesting
- Clean visual hierarchy
5. Sequence Diagram
Best for: Interactions between components, API calls, message flows
Use when: Content involves communication between actors/systems over time
Key features:
- - Timeline-based layout
- Clear actor separation
- Activation boxes for processes
6. State Diagram
Best for: System states, status transitions, lifecycle stages
Use when: Content describes states and transitions between them
Key features:
- - Clear state nodes
- Labeled transitions
- Start and end states
Critical Syntax Rules
Always follow these rules to prevent parsing errors:
Rule 1: Avoid List Syntax Conflicts
CODEBLOCK0
Rule 2: Subgraph Naming
CODEBLOCK1
Rule 3: Node References
CODEBLOCK2
Rule 4: Special Characters in Node Text
CODEBLOCK3
Rule 5: Arrow Types
- -
--> solid arrow - INLINECODE4 dashed arrow (for supporting systems, optional paths)
- INLINECODE5 thick arrow (for emphasis)
- INLINECODE6 invisible link (for layout only)
For complete syntax reference and edge cases, see references/syntax-rules.md
Configuration Options
All diagrams accept these parameters:
Layout:
- -
direction: "vertical" (TB), "horizontal" (LR), "right-to-left" (RL), "bottom-to-top" (BT) - INLINECODE8 : "portrait" (default), "landscape" (wide), "square"
Detail Level:
- -
simple: Core elements only, minimal labels - INLINECODE10 : Balanced detail with key descriptions (default)
- INLINECODE11 : Full annotations, explanations, and metadata
- INLINECODE12 : Optimized for slides (larger text, fewer details)
Style:
- -
minimal: Monochrome, clean lines - INLINECODE14 : Semantic colors, clear hierarchy (default)
- INLINECODE15 : Vibrant colors, high contrast
- INLINECODE16 : Formal styling for papers/documentation
Additional Options:
- -
show_legend: true/false - Include color/symbol legend - INLINECODE18 : true/false - Add sequence numbers to steps
- INLINECODE19 : string - Add diagram title
Example Usage Patterns
Pattern 1: Basic request
CODEBLOCK4
Pattern 2: With configuration
CODEBLOCK5
Pattern 3: Comparison
CODEBLOCK6
Workflow
- 1. Understand the content
- Identify main concepts, entities, and relationships
- Determine hierarchy or sequence
- Note any comparisons or contrasts
- 2. Select diagram type
- Match content structure to diagram type
- Consider user's presentation context
- Default to process flow if ambiguous
- 3. Choose configuration
- Apply user-specified options
- Use sensible defaults for unspecified options
- Optimize for readability
- 4. Generate Mermaid code
- Follow all syntax rules strictly
- Use semantic naming (descriptive IDs)
- Apply consistent styling
- Test for common errors:
* No "number. space" patterns in node text
* All subgraphs use ID["display name"] format
* All node references use IDs not display names
- 5. Output with context
- Wrap in ```mermaid code fence
- Add brief explanation of diagram structure
- Mention rendering compatibility (Obsidian, GitHub, etc.)
- Offer to adjust or create variations
Color Scheme Defaults
Standard professional palette:
- - Green (#d3f9d8/#2f9e44): Input, perception, start states
- Red (#ffe3e3/#c92a2a): Planning, decision points
- Purple (#e5dbff/#5f3dc4): Processing, reasoning
- Orange (#ffe8cc/#d9480f): Actions, tool usage
- Cyan (#c5f6fa/#0c8599): Output, execution, results
- Yellow (#fff4e6/#e67700): Storage, memory, data
- Pink (#f3d9fa/#862e9c): Learning, optimization
- Blue (#e7f5ff/#1971c2): Metadata, definitions, titles
- Gray (#f8f9fa/#868e96): Neutral elements, traditional systems
Common Patterns
Swimlane Pattern (Grouping)
CODEBLOCK7
Feedback Loop Pattern
CODEBLOCK8
Hub and Spoke Pattern
CODEBLOCK9
Quality Checklist
Before outputting, verify:
- - [ ] No "number. space" patterns in any node text
- [ ] All subgraphs use proper ID syntax
- [ ] All arrows use correct syntax (-->, -.->)
- [ ] Colors applied consistently
- [ ] Layout direction specified
- [ ] Style declarations present
- [ ] No ambiguous node references
- [ ] Compatible with Obsidian/GitHub renderers
- [ ] No Emoji in any node text - use text labels or color coding instead
References
For detailed syntax rules and troubleshooting, see:
Mermaid 可视化工具
概述
将文本内容转换为简洁、专业的 Mermaid 图表,优化用于演示和文档。自动处理常见语法陷阱(列表语法冲突、子图命名、间距问题),确保图表在 Obsidian、GitHub 及其他支持 Mermaid 的平台上正确渲染。
快速开始
创建 Mermaid 图表时:
- 1. 分析内容 - 识别关键概念、关系和流程
- 选择图表类型 - 选择最合适的可视化方式(参见下方图表类型)
- 选择配置 - 确定布局、详细程度和样式
- 生成图表 - 创建语法正确的 Mermaid 代码
- 以 Markdown 输出 - 包裹在正确的代码块中,可选添加说明
默认假设:
- - 垂直布局(TB),除非要求水平布局
- 中等详细程度(在简洁与信息量之间取得平衡)
- 专业配色方案,使用语义化颜色
- 兼容 Obsidian/GitHub 的语法
图表类型
1. 流程图表(graph TB/LR)
最佳用途: 工作流、决策树、顺序流程、AI 智能体架构
适用场景: 内容描述步骤、阶段或一系列操作
主要特点:
- - 通过子图实现泳道,用于分组相关步骤
- 箭头标签表示转换
- 反馈循环和分支
- 颜色编码的阶段
配置选项:
- - layout:vertical(垂直,TB)、horizontal(水平,LR)
- detail:simple(仅核心步骤)、standard(含描述)、detailed(含注释)
- style:minimal(极简)、professional(专业)、colorful(多彩)
2. 循环流程图(graph TD 配合循环布局)
最佳用途: 循环过程、持续改进循环、智能体反馈系统
适用场景: 内容强调迭代、反馈或循环关系
主要特点:
- - 中心枢纽与辐射元素
- 弯曲的反馈箭头
- 清晰的循环指示器
3. 对比图表(graph TB 配合并行路径)
最佳用途: 前后对比、A 与 B 分析、传统与现代系统对比
适用场景: 内容对比两种或多种方法或系统
主要特点:
- - 并排布局
- 中心对比节点
- 通过颜色/样式实现清晰区分
4. 思维导图
最佳用途: 层级概念、知识组织、主题分解
适用场景: 内容具有层级结构,存在清晰的父子关系
主要特点:
5. 时序图
最佳用途: 组件间交互、API 调用、消息流
适用场景: 内容涉及参与者/系统之间的通信
主要特点:
6. 状态图
最佳用途: 系统状态、状态转换、生命周期阶段
适用场景: 内容描述状态及其之间的转换
主要特点:
关键语法规则
始终遵循以下规则以防止解析错误:
规则 1:避免列表语法冲突
❌ 错误:[1. Perception] → 触发不支持的 Markdown:列表
✅ 正确:[1.Perception] → 移除句点后的空格
✅ 正确:[① Perception] → 使用带圈数字(①②③④⑤⑥⑦⑧⑨⑩)
✅ 正确:[(1) Perception] → 使用括号
✅ 正确:[Step 1: Perception] → 使用Step前缀
规则 2:子图命名
❌ 错误:subgraph AI Agent Core → 名称中包含空格且未加引号
✅ 正确:subgraph agent[AI Agent Core] → 使用 ID 加显示名称
✅ 正确:subgraph agent → 仅使用简单 ID
规则 3:节点引用
❌ 错误:Title --> AI Agent Core → 直接引用显示名称
✅ 正确:Title --> agent → 引用子图 ID
规则 4:节点文本中的特殊字符
✅ 对包含空格的文本使用引号:[Text with spaces]
✅ 转义或避免:引号 → 改用『』
✅ 转义或避免:括号 → 改用「」
✅ 仅在圆形节点中使用换行:((Text
Break))
规则 5:箭头类型
- - --> 实线箭头
- -.-> 虚线箭头(用于支持系统、可选路径)
- ==> 粗箭头(用于强调)
- ~~~ 不可见链接(仅用于布局)
如需完整的语法参考和边界情况,请参见 references/syntax-rules.md
配置选项
所有图表均接受以下参数:
布局:
- - direction:vertical(垂直,TB)、horizontal(水平,LR)、right-to-left(从右到左,RL)、bottom-to-top(从下到上,BT)
- aspect:portrait(纵向,默认)、landscape(横向,宽屏)、square(方形)
详细程度:
- - simple:仅核心元素,最少标签
- standard:平衡的详细程度,包含关键描述(默认)
- detailed:完整注释、说明和元数据
- presentation:针对幻灯片优化(更大字体,更少细节)
样式:
- - minimal:单色,简洁线条
- professional:语义化颜色,清晰层级(默认)
- colorful:鲜艳颜色,高对比度
- academic:适合论文/文档的正式样式
附加选项:
- - show_legend:true/false - 包含颜色/符号图例
- numbered:true/false - 为步骤添加序号
- title:字符串 - 添加图表标题
使用模式示例
模式 1:基本请求
用户:可视化软件开发生命周期
响应:[分析 → 选择 graph TB → 以标准详细程度生成]
模式 2:带配置
用户:创建我们销售流程的水平流程图,需要大量细节
响应:[分析 → 选择 graph LR → 以详细级别生成]
模式 3:对比
用户:对比传统 AI 与 AI 智能体
响应:[分析 → 选择对比布局 → 以对比样式生成]
工作流程
- 1. 理解内容
- 识别主要概念、实体和关系
- 确定层级或顺序
- 注意任何对比或对照
- 2. 选择图表类型
- 将内容结构与图表类型匹配
- 考虑用户的演示上下文
- 如果不明确,默认使用流程图表
- 3. 选择配置
- 应用用户指定的选项
- 对未指定的选项使用合理的默认值
- 优化可读性
- 4. 生成 Mermaid 代码
- 严格遵循所有语法规则
- 使用语义化命名(描述性 ID)
- 应用一致的样式
- 测试常见错误:
* 节点文本中无数字. 空格模式
* 所有子图使用 ID[显示名称] 格式
* 所有节点引用使用 ID 而非显示名称
- 5. 输出并附上下文
- 包裹在 mermaid 代码块中
- 添加图表结构的简要说明
- 提及渲染兼容性(Obsidian、GitHub 等)
- 提供调整或创建变体的选项
配色方案默认值
标准专业调色板:
- - 绿色(#d3f9d8/#2f9e44):输入、感知、起始状态
- 红色(#ffe3e3/#c92a2a):规划、决策点
- 紫色(#e5dbff/#5f3dc4):处理、推理
- 橙色(#ffe8cc/#d9480f):操作、工具使用
- 青色(#c5f6fa/#0c8599):输出、执行、结果
- 黄色(#fff4e6/#e67700):存储、记忆、数据
- 粉色(#f3d9fa/#862e9c):学习、优化
- 蓝色(#e7f5ff/#1971c2):元数据、定义、标题
- 灰色(#f8f9fa/#868e96):中性元素、传统系统