beautiful-mermaid

Render Mermaid diagrams as SVG or ASCII art using the beautiful-mermaid library. Ultra-fast rendering with 15 built-in themes and Shiki VS Code theme support. Use when: (1) Creating diagrams from Mermaid syntax, (2) Rendering flowcharts, state, sequence, class, or ER diagrams, (3) Generating ASCII diagrams for terminal/markdown output, (4) Theming diagrams to match VS Code color schemes, (5) Embedding diagrams in documentation or web UIs. Supports SVG output with live theme switching and ASCII/Unicode output for plain text contexts.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "beautiful-mermaid" with this command: npx skills add alexmikhalev/beautiful-mermaid/alexmikhalev-beautiful-mermaid-beautiful-mermaid

Beautiful Mermaid Diagram Rendering

Render Mermaid diagrams as SVG (for UIs) or ASCII/Unicode (for terminals and markdown).

Quick Start

1. Install Dependencies

npm install beautiful-mermaid

Or run the setup script:

bash scripts/setup.sh

2. Render SVG

import { renderMermaid } from 'beautiful-mermaid'

const svg = await renderMermaid(`
  graph LR
    A[Start] --> B{Decision}
    B -->|Yes| C[Action]
    B -->|No| D[End]
`)

3. Render ASCII

import { renderMermaidAscii } from 'beautiful-mermaid'

const ascii = renderMermaidAscii(`graph LR; A --> B --> C`)
// Output:
// +---+     +---+     +---+
// | A |---->| B |---->| C |
// +---+     +---+     +---+

Core API

renderMermaid(text, options?): Promise<string>

Returns SVG string. Options:

OptionTypeDefaultDescription
bgstring"#FFFFFF"Background color
fgstring"#27272A"Foreground color
fontstring"Inter"Font family
transparentbooleanfalseTransparent background
linestringautoEdge/connector color
accentstringautoArrow heads, highlights
mutedstringautoSecondary text, labels
surfacestringautoNode fill tint
borderstringautoNode stroke

renderMermaidAscii(text, options?): string

Returns ASCII/Unicode string. Synchronous. Options:

OptionTypeDefaultDescription
useAsciibooleanfalseUse ASCII chars instead of Unicode
paddingXnumber5Horizontal node spacing
paddingYnumber5Vertical node spacing
boxBorderPaddingnumber1Inner box padding

Theming

Mono Mode (Two Colors)

Provide only bg and fg. All other colors are derived automatically:

const svg = await renderMermaid(diagram, {
  bg: '#1a1b26',
  fg: '#a9b1d6'
})

Built-in Themes

import { renderMermaid, THEMES } from 'beautiful-mermaid'

const svg = await renderMermaid(diagram, THEMES['tokyo-night'])

Available themes: zinc-light, zinc-dark, tokyo-night, tokyo-night-storm, tokyo-night-light, catppuccin-mocha, catppuccin-latte, nord, nord-light, dracula, github-light, github-dark, solarized-light, solarized-dark, one-dark.

Shiki Theme Integration

import { getSingletonHighlighter } from 'shiki'
import { renderMermaid, fromShikiTheme } from 'beautiful-mermaid'

const highlighter = await getSingletonHighlighter({
  themes: ['vitesse-dark']
})
const colors = fromShikiTheme(highlighter.getTheme('vitesse-dark'))
const svg = await renderMermaid(diagram, colors)

See themes.md for complete theming reference.


Supported Diagrams

TypeSyntaxExample
Flowchartgraph TD/LR/BT/RLgraph LR; A --> B
StatestateDiagram-v2stateDiagram-v2\n[*] --> Active
SequencesequenceDiagramsequenceDiagram\nAlice->>Bob: Hello
ClassclassDiagram`classDiagram\nAnimal <
ERerDiagram`erDiagram\nCUSTOMER

Common Patterns

Save SVG to File

import { renderMermaid, THEMES } from 'beautiful-mermaid'
import { writeFile } from 'fs/promises'

const svg = await renderMermaid(diagram, THEMES['github-dark'])
await writeFile('diagram.svg', svg)

Generate ASCII for Markdown

import { renderMermaidAscii } from 'beautiful-mermaid'

const ascii = renderMermaidAscii(diagram, { useAscii: true })
const markdown = `## Architecture\n\n\`\`\`\n${ascii}\n\`\`\``

Live Theme Switching (Browser)

SVG output uses CSS custom properties. Switch themes without re-rendering:

svgElement.style.setProperty('--bg', '#282a36')
svgElement.style.setProperty('--fg', '#f8f8f2')

Reference Files

FileContents
themes.mdComplete theming guide, color derivation, custom themes
ascii-rendering.mdASCII mode options, Unicode vs ASCII, formatting

Troubleshooting

"Cannot find module 'beautiful-mermaid'": Run npm install beautiful-mermaid

Empty SVG output: Verify Mermaid syntax is valid. Test at mermaid.live first.

Fonts not rendering: Ensure the font is available. Use web-safe fonts or embed font CSS.

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

beautiful-mermaid

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

beautiful-mermaid

No summary provided by upstream source.

Repository SourceNeeds Review
General

beautiful-mermaid

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

beautiful-mermaid

No summary provided by upstream source.

Repository SourceNeeds Review