Crafter Station Docs
Guides

Render a Mermaid diagram from the CLI

Render Mermaid diagrams directly in your terminal with one npx command. No headless browser, no Chromium download, zero dependencies.

npx @crafter/mermaid-cli diagram.mmd

That renders the diagram in your terminal with ANSI colors and Unicode box drawing. No headless browser, no Chromium download: the whole engine is 30.5KB.

From stdin

echo "graph TD; A-->B-->C" | npx @crafter/mermaid-cli

Pick a theme

npx @crafter/mermaid-cli --theme tokyo-night diagram.mmd
npx @crafter/mermaid-cli --list-themes   # 30 available

Options

FlagDescription
--theme <name>Theme name (default: one-hunter)
--width <n>Terminal width (default: auto-detect)
--compactCompact spacing
--list-themesList all 30 themes

Install permanently

npm install -g @crafter/mermaid-cli
crafter-mermaid diagram.mmd

How is this different from @mermaid-js/mermaid-cli?

The official @mermaid-js/mermaid-cli renders by launching a headless Chromium via Puppeteer, a heavyweight install that doesn't work in many CI/sandbox environments. @crafter/mermaid-cli uses @crafter/mermaid, a from-scratch rendering engine with zero dependencies and a synchronous API, so it runs anywhere Node runs, instantly.

Need SVG output instead of terminal rendering? Use the library directly:

import { render } from "@crafter/mermaid"
const svg = render("graph TD; A-->B")

On this page