Skip to content

diagramkitDiagram files to images, with dark mode

Render .mermaid, .excalidraw, and .drawio files to SVG/PNG/JPEG/WebP with automatic light and dark theme variants.

Quick Start

bash
# Install
npm add diagramkit

# Install the browser engine once per environment
npx diagramkit warmup

# Optional: required for PNG, JPEG, and WebP output
npm add sharp

# Render all diagrams in the current directory
npx diagramkit render .

Output goes to a .diagrams/ folder next to each source file:

docs/
  architecture.mermaid
  .diagrams/
    architecture-light.svg
    architecture-dark.svg
    diagrams.manifest.json

Use a <picture> element for automatic light/dark switching in HTML:

html
<picture>
  <source srcset=".diagrams/architecture-dark.svg" media="(prefers-color-scheme: dark)">
  <img src=".diagrams/architecture-light.svg" alt="Architecture diagram">
</picture>