📊 beautiful-mermaid
Renders Mermaid diagrams as SVG and PNG using the Beautiful Mermaid library — with rich visual themes, high-resolution output (4K), and integration with agent-browser for screenshot capture.
🧩 What it is / what it does
Precise definition
beautiful-mermaid is a Claude Code skill that renders Mermaid diagrams as SVG and PNG using the Beautiful Mermaid library. The operation is bidirectional: it accepts code .mmd (or a natural-language description) and produces always both formats — vector SVG and high-resolution PNG (4K, 3840×2160 viewport, diagram width of at least 1200px).
🎣 When it triggers
The skill's official trigger (field description) you need to:
"Render Mermaid diagrams as SVG and PNG using the Beautiful Mermaid library. Use when the user asks to render a Mermaid diagram."
Situations that trigger the skill
If the user mentions "Mermaid diagram," "Mermaid code," ".mmd file," or explicitly asks to render, Claude activates this skill. There’s no need to mention "beautiful-mermaid" — the trigger is the type of diagram.
🚀 How it improves your pages
Technical diagrams significantly improve the quality of documentation pages, courses, and dashboards. beautiful-mermaid delivers this with a single command.
- ✓ Embed SVG directly in the HTML page (vector, no quality loss)
- ✓ Use high-resolution PNGs in presentations and slides
- ✓ Document API flows with sequenceDiagram
- ✓ Visualize database architecture with erDiagram
- ✓ Choose a theme suited to the context (dark/light/tokyo-night)
- ✗ Use `-- label -->` (space-dash) — prefer `-->|label|`
- ✗ Reuse node IDs — each node ID must be unique
- ✗ Leave square brackets open in node labels
- ✗ Use for diagrams that require complex interactivity
- ✗ Insert special characters in labels without quotation marks
The SVG generated by beautiful-mermaid can be copied and embedded directly into the HTML of modules like the one you're reading now. It's the same technique used for this course's futuristic SVGs — vector-based, lightweight, with no external dependencies.
⚙️ How it works under the hood
5 sequential steps, always in this order — from Mermaid code to the two final files.
references/mermaid-syntax.md. If the code already exists, validate the syntax.<output>.svg in the current directory.bun run scripts/render.ts --code "graph TD; A-->B" --output diagram --theme default
# ou via arquivo:
bun run scripts/render.ts --input diagram.mmd --output diagram --theme tokyo-night
# runtimes alternativos:
npx tsx scripts/render.ts --code "..." --output diagram
deno run --allow-read --allow-write --allow-net scripts/render.ts --code "..."
bun run scripts/create-html.ts --svg diagram.svg --output diagram.html
diagram.svg e diagram.png in the working directory.Beautiful Mermaid library— rendering corescripts/render.ts— SVG renderingscripts/create-html.ts— HTML wrapperagent-browser— Playwright / 4K screenshotbun / tsx / deno— TypeScript runtimes
default— clear Mermaid conventiondark— dark by defaultforest— green tonesneutral— no strong colortokyo-night— modern dark neonbase— minimalist
- Theme not applied: check
--bge--fgCSS in the output SVG - Cropped diagram: use
-->|label|— never-- label --> - Empty/malformed SVG: check for unique node IDs and closed brackets in labels
💬 Practical example + Ready-to-use PROMPT
Two concrete scenarios: render existing code and generate from scratch based on a description.
Mermaid syntax — direct examples
flowchart TD
A([Início]) --> B[/Receber input/]
B --> C{Válido?}
C -->|Sim| D[Processar]
C -->|Não| E[Retornar erro]
D --> F[(Salvar no DB)]
F --> G([Fim])
E --> G
sequenceDiagram
participant U as Usuário
participant A as App
participant S as Servidor
U->>A: Login (email/senha)
A->>S: POST /auth/login
S-->>A: JWT token
A-->>U: Acesso liberado
Note over S: Valida credenciais
Always use C -->|Sim| D with a pipe. Never C -- Sim --> D (spaces or dashes can cause incomplete rendering, according to SKILL.md).
Renderize o diagrama Mermaid abaixo como SVG e PNG.
Use o tema tokyo-night. Salve como auth-flow.
```mermaid
sequenceDiagram
participant U as Usuário
participant A as App
participant S as Servidor
U->>A: Login (email/senha)
A->>S: POST /auth/login
S-->>A: JWT token
A-->>U: Acesso liberado
```
Gere e renderize um flowchart Mermaid do pipeline CI/CD:
push → build → testes unitários → testes e2e →
deploy staging → aprovação manual → deploy produção.
Use o tema dark. Salve como cicd-pipeline.
Gere um erDiagram Mermaid para um sistema de e-commerce
com entidades: Customer, Order, Product, OrderItem, Payment.
Renderize com tema forest e depois copie o SVG
inline para o arquivo docs/schema.html.
🧬 Works well with / limitations
beautiful-mermaid fits into an ecosystem of visualization and support skills. Understanding where each tool starts and ends helps avoid poor choices.
📊 beautiful-mermaid vs ✏️ excalidraw
- → Technical diagrams precise and structured
- → Declarative syntax — you define the logic, the library organizes the layout
- → Style polished, professional, curated themes
- → Exportable SVG + PNG for documentation
- → Ideal for: architecture, code flows, databases, CI/CD
- → Diagrams "by hand", sketchy, exploratory
- → Hand-drawn style — communicates "work in progress"
- → Great for wireframes, initial architecture drafts
- → Interactive — you can edit it in the browser
- → Ideal for: UX wireframes, visual brainstorming, UI sketches
Works with other course skills
- ✓ Need technical diagrams in documentation
- ✓ Want an embeddable SVG for HTML or a PNG for a slide
- ✓ The diagram has a clear logical structure (flow, sequence, state)
- ✓ Requires multiple visual themes
- ✗ The diagram is a wireframe or conceptual sketch (→ excalidraw)
- ✗ Need interactive diagrams that can be edited in the browser
- ✗ The content is an animation or 3D diagram (→ 3d-animation-creator)
- ✗ Need full control over the visual layout of each element
📋 Module 4.1 Summary
What you learned
- ✓beautiful-mermaid renders Mermaid as SVG + PNG using the Beautiful Mermaid library
- ✓The trigger is a request from the user to render a Mermaid diagram — any type
- ✓The pipeline has 5 steps: validate → render.ts → create-html.ts → agent-browser (Playwright) → clean up
- ✓PNG is captured in 4K (3840×2160) with a minimum diagram width of 1200px
- ✓Always use
-->|label|for edge labels — never space-hyphen - ✓Mermaid = precise technical diagrams; Excalidraw = sketchy drafts and wireframes
- ✓The generated SVG can be embedded inline in HTML — the same technique as the SVGs in this course
The skill that generates Excalidraw-style "hand-drawn" diagrams—wireframes, architecture drafts, and UI sketches with an informal look that communicates "under construction".