with one click
preview-mermaid
// Render and preview Mermaid diagrams in browser with support for flowcharts, sequence diagrams, class diagrams, and more
// Render and preview Mermaid diagrams in browser with support for flowcharts, sequence diagrams, class diagrams, and more
| name | preview-mermaid |
| description | Render and preview Mermaid diagrams in browser with support for flowcharts, sequence diagrams, class diagrams, and more |
| user-invocable | true |
| commands | ["preview-mermaid"] |
Interactive Mermaid diagram viewer that renders flowcharts, sequence diagrams, class diagrams, ER diagrams, state diagrams, Gantt charts, pie charts, and more.
When the user asks to preview a Mermaid diagram, DO NOT build HTML manually. Use the Bash tool to execute this skill's run.sh script:
# Preview a file
./run.sh diagram.mmd
# Pipe content
echo "graph TD
A-->B" | ./run.sh
The script handles all HTML generation and automatically opens the result in the browser. Do NOT open the file manually to avoid duplicate tabs.
# Preview a Mermaid diagram file
/preview-mermaid diagram.mmd
# Pipe Mermaid content (preferred for temporary content)
cat flowchart.mermaid | /preview-mermaid
echo "graph TD\n A-->B" | /preview-mermaid
# With custom background color
/preview-mermaid sequence.mmd --background "#ffffff"
Best Practice: For temporary or generated content, prefer piping over creating temporary files. This avoids cluttering your filesystem and the content is automatically cleaned up.
The script works with sensible defaults but supports these flags for flexibility:
-o, --output PATH - Custom output path--no-browser - Skip browser, output file path onlyUse this skill when the user wants to:
Natural language requests:
.mmd, .mermaidgraph TD
A[Start] --> B{Decision}
B -->|Yes| C[Process]
B -->|No| D[End]
C --> D
sequenceDiagram
Alice->>John: Hello John!
John-->>Alice: Great to hear from you!
classDiagram
Animal <|-- Duck
Animal : +int age
Animal: +isMammal()
stateDiagram-v2
[*] --> Still
Still --> Moving
Moving --> Still
Moving --> Crash
Crash --> [*]
The skill generates a standalone HTML file at:
.preview-skills/mermaid/{filename}.html
The file is self-contained and can be:
This skill is standalone and includes all dependencies:
lib/templates/To modify the skill:
config.sh for configurationtemplates/scripts/mermaid-renderer.js for behaviortemplates/styles/diagram.css for stylingrun.sh to test changesFor Mermaid syntax and examples:
Render and preview CSV files in browser with interactive sorting, filtering, and column statistics
Create interactive 2D data visualizations using D3.js with zoom, pan, and custom rendering
Git diff preview tool with GitHub-style formatting and interactive features
Render and preview JSON files in browser with syntax highlighting, collapsible tree view, and search
Create interactive maps with markers, routes, and geographic data using Leaflet
Render and preview Markdown files in browser with GitHub-flavored formatting and syntax highlighting