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

@datalackey/nx-graph-to-mermaid

v1.1.8

Published

Auto-generates a Mermaid task flow diagram from an NX `project.json` file — with optional CI drift detection and Markdown injection support.

Downloads

701

Readme

NX-graph-to-mermaid

Deterministically generates Mermaid task flow diagrams from NX project.json config files.

NX-graph-to-mermaid is an NX plugin that generates deterministic Mermaid task flow diagrams from an NX project.json file — with optional Markdown injection and CI drift detection support.

It operates purely on the specified project.json and renders intra-project target dependencies only. It does not resolve cross-project or workspace-level graph relationships.

So, basically: no monorepo support (but contributions are always welcome!)

In the above quick demo, we use the nx-graph-to-mermaid plugin to update this README file:

  # Sample Project

  ## Task Graph

  <!-- NX_GRAPH:START -->
  <!-- NX_GRAPH:END -->
  EOF

This image will be generated from the project.json file in the root of this repository:

graph TD

  build["build<br/>Build the project"]
  task_graph_inject
  test["test<br/>Run unit tests"]

  build --> test

See Example for how project.json relates to the corresponding generated Mermaid diagram.


Overview

Plugin behavior is controlled entirely by options.mode.

Supported modes:

  • generate — Generate a deterministic Mermaid diagram from a specified project.json.
  • inject — Inject a previously generated Mermaid document into a Markdown file between NX_GRAPH markers.
  • check — Validate that an existing Mermaid diagram matches what would be generated from project.json.
  • update — Regenerate the Mermaid diagram and inject it into a Markdown file.

Adding Documentation To NX Configuration

Your project.json already defines the execution graph of your build.

By extending targets with a description field:

{
  "release": {
    "dependsOn": ["package"],
    "description": "Full release pipeline"
  }
}

your documentation will co-reside with configuration metadata.

nx-graph-to-mermaid compiles that metadata into a deterministic Mermaid diagram suitable for Markdown rendering.


Installation

npm install --save-dev @datalackey/nx-graph-to-mermaid

Extending project.json

Add a description field to any target:

{
  "targets": {
    "build": {
      "dependsOn": ["lint", "test"],
      "description": "Runs lint and test"
    }
  }
}

NX ignores unknown fields, so this is safe.


Usage

All modes use the same executor:

"executor": "@datalackey/nx-graph-to-mermaid"

Behavior is controlled exclusively by options.mode.

Diagram Injection Targets Special Start/End Markers

NX-graph-to-mermaid uses fixed markers to inject the generated Mermaid diagram into a Markdown file:

<!-- NX_GRAPH:START -->
<!-- NX_GRAPH:END -->

Generate Mode

Add a target:

{
  "task-graph:generate": {
    "executor": "@datalackey/nx-graph-to-mermaid",
    "options": {
      "mode": "generate",
      "projectJsonPath": "project.json",
      "generatedMermaidPath": "docs/task-graph.md"
    }
  }
}

This mode:
Reads the specified project.json, extracts all target definitions, resolves dependsOn relationships, and incorporates optional description metadata. It then renders a fully deterministic Mermaid diagram and writes it to disk.

What it does:

  • Reads target definitions
  • Reads dependsOn relationships
  • Reads optional description metadata
  • Sorts targets deterministically
  • Sorts dependencies deterministically
  • Outputs normalized Mermaid markup

Run:

npx NX run my-project:task-graph:generate

Inject Mode

Add a target:

{
  "task-graph:inject": {
    "executor": "@datalackey/nx-graph-to-mermaid",
    "options": {
      "mode": "inject",
      "projectJsonPath": "project.json",
      "generatedMermaidPath": "docs/task-graph.md",
      "markdownPath": "README.md"
    }
  }
}

This mode:
Performs deterministic Markdown injection only. It does not generate a graph. It reads a previously generated Mermaid artifact and replaces the content between fixed markers inside the specified Markdown file.

It requires:

  • A path to the generated Mermaid document
  • A path to the target Markdown file

Run:

npx NX run my-project:task-graph:inject

Update Mode (Generate + Inject)

Add a target:

{
  "task-graph:update": {
    "executor": "@datalackey/nx-graph-to-mermaid",
    "options": {
      "mode": "update",
      "projectJsonPath": "project.json",
      "markdownPath": "README.md",
      "generatedMermaidPath": "docs/task-graph.md"
    }
  }
}

This mode:
Combines generation and injection in a single deterministic operation. It regenerates the Mermaid diagram from project.json, injects it into the specified Markdown file between NX_GRAPH markers, and optionally writes the generated artifact to disk.

Run:

npx NX run my-project:task-graph:update

Check Mode (CI Drift Detection)

Add a target:

{
  "task-graph:check": {
    "executor": "@datalackey/nx-graph-to-mermaid",
    "options": {
      "mode": "check",
      "projectJsonPath": "project.json",
      "generatedMermaidPath": "docs/task-graph.md"
    }
  }
}

This mode:
Regenerates the diagram in memory and compares it against the committed Mermaid artifact. If any difference is detected, it returns { success: false }, making it suitable for CI enforcement.

Run:

npx NX run my-project:task-graph:check

If drift is detected:

  • A failure message is printed
  • The executor returns { success: false }
  • CI exits with a non-zero status

This prevents stale diagrams from being merged.


Determinism

Output is fully deterministic:

  • Targets sorted alphabetically
  • Dependencies sorted
  • Whitespace normalized
  • No timestamps
  • No randomness

The tool operates purely on project.json. Identical input → identical output.


Example

Given:

{
  "targets": {
    "release": {
      "dependsOn": ["package"],
      "description": "Full release pipeline"
    },
    "package": {
      "dependsOn": ["build"],
      "description": "Runs npm pack"
    }
  }
}

Generated output:

graph TD

package["package<br/>Runs npm pack"]
release["release<br/>Full release pipeline"]

release --> package

License

MIT