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

@boneskull/typedoc-plugin-mermaid

v0.2.0

Published

TypeDoc plugin for rendering Mermaid diagrams

Readme

@boneskull/typedoc-plugin-mermaid

TypeDoc plugin for rendering Mermaid diagrams

This plugin transforms Mermaid code blocks in your TypeDoc documentation into rendered diagrams. It automatically adapts to TypeDoc's light and dark themes.

Features

  • Renders Mermaid diagrams from fenced code blocks
  • Automatic dark/light theme switching based on TypeDoc theme
  • Graceful fallback to plain code when JavaScript is disabled
  • Loads Mermaid from CDN or locally from your node_modules
  • Responsive diagram sizing

Install

npm install @boneskull/typedoc-plugin-mermaid -D

Usage

Add the plugin to your typedoc.json:

{
  "ignoredHighlightLanguages": ["mermaid"],
  "plugin": ["@boneskull/typedoc-plugin-mermaid"]
}

The ignoredHighlightLanguages option silences TypeDoc warnings about mermaid not being a recognized highlight language (this plugin handles it separately).

Or via command line:

typedoc --plugin @boneskull/typedoc-plugin-mermaid

Then use Mermaid code blocks in your documentation comments:

/**
 * Represents a workflow state machine.
 *
 * ```mermaid
 * stateDiagram-v2
 *   [*] --> Idle
 *   Idle --> Processing: start()
 *   Processing --> Complete: finish()
 *   Processing --> Error: fail()
 *   Complete --> [*]
 *   Error --> Idle: retry()
 * ```
 */
export class Workflow {
  // ...
}

Supported Diagram Types

Any diagram type supported by Mermaid works:

  • Flowcharts
  • Sequence diagrams
  • Class diagrams
  • State diagrams
  • Entity Relationship diagrams
  • Gantt charts
  • Pie charts
  • And more...

See the Mermaid documentation for all diagram types and syntax.

Configuration

mermaidSource

Where to load the Mermaid library from. Defaults to "cdn".

| Value | Description | | --------- | ---------------------------------------------------------------- | | "cdn" | Load from a CDN URL (configured via mermaidCdnUrl) | | "local" | Copy mermaid's ESM bundle from node_modules to the docs output |

typedoc.json:

{
  "mermaidSource": "local"
}

When using "local", you must install mermaid in your project:

npm install mermaid -D

The plugin copies mermaid's ESM entry point and chunks directory to assets/mermaid/ in your docs output. Diagram-specific code is lazy-loaded on demand, so only the diagram types you actually use are downloaded by browsers.

Use "local" when you need:

  • Offline documentation
  • Air-gapped or restricted network environments
  • Pinned mermaid versions bundled with your docs
  • Full control over the mermaid distribution

mermaidCdnUrl

URL to load the Mermaid library from. Defaults to https://unpkg.com/mermaid@latest/dist/mermaid.esm.min.mjs.

Only used when mermaidSource is "cdn" (the default).

This is useful for using alternative CDNs or self-hosting the library.

typedoc.json:

{
  "mermaidCdnUrl": "https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs"
}

Command line:

typedoc --mermaidCdnUrl "https://your-cdn.example.com/mermaid.esm.min.mjs"

How It Works

The plugin hooks into TypeDoc's HTML rendering pipeline and:

  1. Finds <pre><code class="mermaid"> blocks in the output
  2. Wraps them in a container with both dark and light themed versions
  3. Injects CSS and JavaScript to render diagrams and switch themes
  4. Preserves the original code as a fallback for non-JS environments

Diagrams are rendered client-side using the Mermaid library, loaded either from a CDN or from a local copy in your docs output (depending on mermaidSource).

Acknowledgments

This plugin is adapted from typedoc-plugin-mermaid by kamiazya.

Differences from the Original

| Feature | This Plugin | kamiazya/typedoc-plugin-mermaid | | --------------------- | ------------------------------------------- | ------------------------------- | | TypeDoc version | 0.27+ | 0.22–0.26 | | Rendering strategy | Dual dark/light diagrams with CSS switching | Single diagram per block | | Theme support | Automatic dark/light based on TypeDoc theme | Manual theme configuration | | @mermaid JSDoc tag | Not supported | Supported | | Mermaid loading | CDN or local ESM bundle with lazy chunks | Bundled UMD or CDN | | Offline support | Yes (with mermaidSource: "local") | Yes (when bundled) | | Configuration options | mermaidSource, mermaidCdnUrl | mermaidVersion, mermaidCdn |

Why a new plugin?

The original plugin stopped working with TypeDoc 0.27+ due to breaking API changes and appears unmaintained.

License

Copyright © 2026 Christopher "boneskull" Hiller. Licensed BlueOak-1.0.0.