npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mermaid-animator

v0.7.0

Published

Animated, interactive Mermaid.js diagram viewer with pan, zoom, and click-to-inspect

Downloads

889

Readme

mermaid-animator   CI npm license

Animated, interactive Mermaid.js diagram viewer. Renders Mermaid code as a live SVG with colorized edges and glowing dots that travel along connections, plus pan, zoom, and click-to-inspect.

Try the playground

Supports all Mermaid diagram types: flowcharts, sequence diagrams, class diagrams, state diagrams, ER diagrams, and more.

Features

  • Colorized edges with glowing dots that travel along all connections simultaneously
  • Each edge gets a distinct color from a vibrant palette
  • Rounded nodes with cluster-colored borders
  • Dark and light themes built in, with full custom theme support
  • Pan and zoom via mouse/touch, with keyboard shortcuts
  • Click any node to highlight its connections and see a detail popover
  • GIF export with traveling dot animation (separate entry point, keeps main bundle small)
  • Works with all Mermaid diagram types
  • Ships as ESM and UMD, with TypeScript declarations

Installation

npm install mermaid-animator mermaid

Usage

<div id="diagram" style="width: 800px; height: 600px;"></div>

<script type="module">
  import { MermaidAnimator } from 'mermaid-animator'

  const animator = await MermaidAnimator.create(
    document.getElementById('diagram'),
    `graph TD
      A[Start] --> B{Decision}
      B -->|Yes| C[Process]
      B -->|No| D[End]
      C --> D`
  )
</script>

Options

const animator = await MermaidAnimator.create(container, code, {
  theme: 'dark',       // 'dark', 'light', or a custom Theme object
  dotSpeed: 0.008,     // dot travel speed (higher = faster)
  dotsPerEdge: 3,      // number of dots per edge
  dotRadius: 3,        // dot size in SVG units
  pan: true,           // enable pan
  zoom: true,          // enable zoom
  inspect: true,       // enable click-to-inspect/hover-to-highlight
  minZoom: 0.1,
  maxZoom: 5,
  mermaid: {}          // extra options passed to mermaid.initialize()
})

Themes

Built-in themes: 'dark' (default) and 'light'.

// Dark theme (default)
MermaidAnimator.create(container, code, { theme: 'dark' })

// Light theme
MermaidAnimator.create(container, code, { theme: 'light' })

// Custom theme
MermaidAnimator.create(container, code, {
  theme: {
    name: 'midnight',
    background: '#0f172a',
    mermaidTheme: 'dark',
    edgeColors: ['#38bdf8', '#c084fc', '#fb7185', '#fbbf24'],
    dotGlowOpacity: 0.35,
    nodeStrokeWidth: 2,
    nodeFillOpacity: 0.2,
    nodeBorderDefault: '#475569',
    clusterStrokeWidth: 1.5,
    clusterFillOpacity: 0.1,
    clusterBorderOpacity: 0.8,
    popoverBackground: '#0f172a',
    popoverText: '#e2e8f0',
    popoverBorder: '#334155',
    popoverIdColor: '#38bdf8',
    popoverSecondaryText: '#94a3b8',
  }
})

The Theme type is exported for TypeScript users:

import type { Theme } from 'mermaid-animator'

Methods

animator.fitToView()        // reset zoom/pan
animator.update(newCode)    // re-render with new Mermaid code
animator.inspect('nodeId')  // programmatically inspect a node
animator.destroy()          // cleanup

Events

animator.on('nodeClick', (node) => {})

CLI

Generate animated GIFs from the command line:

# From a file
mermaid-animator diagram.mmd -o output.gif

# With options
mermaid-animator diagram.mmd -o output.gif --theme light -W 1024 -H 768

# From stdin
cat diagram.mmd | mermaid-animator -o output.gif

# To stdout (pipe to another tool)
mermaid-animator diagram.mmd > output.gif

CLI Options

| Option | Default | Description | |--------|---------|-------------| | -o, --output <file> | stdout | Output GIF path | | -t, --theme <name> | dark | 'dark' or 'light' | | -W, --width <px> | 800 | Max width (aspect ratio preserved) | | -H, --height <px> | 600 | Max height (aspect ratio preserved) | | --fps <n> | 12 | Frames per second | | --frames <n> | 60 | Total animation frames |

Requires puppeteer to be installed (npm install puppeteer).

GIF Export

Export animated diagrams as GIF files with traveling dots. GIF and WebM export are available as a separate import to keep the main bundle small.

import { exportGif } from 'mermaid-animator/export'

const gifBytes = await exportGif(`graph TD
  A[Start] --> B{Decision}
  B -->|Yes| C[Process]
  B -->|No| D[End]
  C --> D`, {
  theme: 'dark'
})

// Download
const blob = new Blob([gifBytes], { type: 'image/gif' })
const url = URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = url
a.download = 'diagram.gif'
a.click()

Export Options

| Option | Default | Description | |--------|---------|-------------| | theme | 'dark' | 'dark', 'light', or a custom Theme object | | width | 800 | Max GIF width in pixels (aspect ratio preserved) | | height | 600 | Max GIF height in pixels (aspect ratio preserved) | | fps | 12 | Frames per second | | totalFrames | 60 | Total animation frames (controls loop duration) | | dotsPerEdge | 3 | Number of dots traveling per edge | | dotRadius | 3 | Dot radius in SVG units | | background | from theme | Background color (overrides theme) | | mermaid | {} | Extra options passed to mermaid.initialize() |

WebM Video Export

Export as WebM video — much smaller files than GIF with full color. Uses the browser's MediaRecorder API (browser-only, not available in Node/CLI).

import { exportVideo } from 'mermaid-animator/export'

const blob = await exportVideo(`graph TD
  A[Start] --> B{Decision}
  B -->|Yes| C[Process]
  B -->|No| D[End]
  C --> D`, {
  theme: 'dark'
})

const url = URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = url
a.download = 'diagram.webm'
a.click()

Accepts the same options as exportGif, plus videoBitsPerSecond (default: 2,000,000).

Keyboard Shortcuts

Keyboard shortcuts are active when the diagram container has focus (click the diagram first).

| Key | Action | |-----|--------| | + / - | Zoom in / out | | 0 | Fit to view | | Escape | Dismiss popover |

UMD / Script Tag

<script src="https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/mermaid-animator/dist/mermaid-animator.umd.js"></script>
<script>
  const { MermaidAnimator } = MermaidAnimatorLib
  MermaidAnimator.create(container, code)
</script>

Development

Requires Node.js >= 22.

git clone https://github.com/dsablic/mermaid-animator.git
cd mermaid-animator
npm install --ignore-scripts=false
npm test                    # run tests
npm run build:all           # build ESM + UMD + export + types
npm run dev                 # serve demo at localhost:3000/demo/
npm run generate-examples   # regenerate example GIFs

License

MIT