Skip to content
Dependency viewer

npm Dependency Graph (package-lock.json Visualizer)

Paste a package-lock.json (or choose the file) to see the dependencies as a diagram and find out why a package is installed, as a path from the root.
It also lists packages that exist in several versions (duplicates), the dependency depth, packages with install scripts, deprecated packages and packages fetched over http or from git. lockfileVersion 1, 2 and 3 yarn.lock (classic and Berry) and pnpm-lock.yaml (v6 and v9) are supported.
The file is read only in your browser: it is never sent to a server and not stored in this browser. The registry is not queried, so latest versions and vulnerabilities are not checked.

The file is read only in your browser and never sent to a server. It is not stored in this browser either.

Overview

Enter a package name to draw only the path from the root to it. With nothing entered, the graph goes from the root down to the chosen depth. Nodes can be dragged. Dashed lines are devDependencies and optional dependencies.

Things worth a look

A check based only on what the lock records. Latest versions, vulnerabilities and licenses are not checked.

Packages with several versions

Each is a separate copy. `npm dedupe` can sometimes reduce them.

Most depended-on packages

Packages with the most direct dependencies

Guide

How to use & features

  • Paste the contents of your npm package-lock.json into the box, or load the file with "Choose a file". A sample is loaded at first.
  • The graph shows the root (your project) and its dependencies down to the chosen depth, from 1 to 4 levels.
  • Enter a package name (`qs`, `[email protected]`, `@babel/core`…) in "Why is it installed?" to draw only the path from the root to it, and to see the path as text below.
  • Click a node to see its version, location, source, dependencies and what requires it. Drag nodes (or use the arrow keys) to rearrange them, and use "Save SVG" to get an image.
  • "Things worth a look" lists packages with install scripts, deprecated packages and packages fetched over http or from git. Below it, a table lists packages installed in several versions.
FAQ

FAQ

  • How can I tell why a package is installed?

    Enter the package name and the tool follows the shortest path from the root, showing something like `your project → express → body-parser → qs`. When the same name is installed in several versions, each path is shown, closest to the root first. Dev-only packages are marked.
  • Which lock files are supported?

    npm's `package-lock.json` (lockfileVersion 1, 2 and 3). `yarn.lock` (classic and Berry) can be read too; `pnpm-lock.yaml` (v6 and v9) is supported too, and yarn.lock records no dev-only flag, install scripts or deprecations, so those checks do not appear. lockfileVersion 1 and yarn.lock do not record the root's direct dependencies, so top-level packages that nothing else requires are treated as direct dependencies.
  • Does it show latest versions or vulnerabilities?

    No. The registry is not queried, so latest versions, vulnerabilities and licenses are not checked. The check uses only what the lock records: install scripts, deprecation notes, sources and versions. Use `npm audit` or similar for vulnerabilities.
  • Is my lock file sent to a server?

    No. The file is read only in your browser and never sent to a server. It is not stored in this browser either.
  • What if the graph is too large to read?

    Reduce the depth or narrow it down with a package name. When there are too many nodes, it draws up to the limit (80) and shows how many were left out.
  • Can I save the graph as an image?

    Yes. There is "Save SVG" (stays sharp when enlarged) and "Save PNG" (2x resolution on a white background, ready to paste into slides or a PR). Both are created in your browser and nothing is sent to a server. Highlight and selection states are not included in the saved image.
Use cases

Common use cases

  • Find out why a package is installed

    See why an unfamiliar package, or an old version of one, is installed, as a path from the root. It hints at which direct dependency to upgrade or remove to get rid of it.
  • Spot duplicated versions

    Lists packages installed in several versions under the same name. Useful when looking for causes of a large bundle.
  • Check install scripts and deprecations

    Find packages that run scripts at install time, and packages recorded as deprecated, from the lock alone. A first lead for reviews and audits.
  • Share the dependency structure as a diagram

    Save the SVG and paste it into a README, design doc or issue. Change the depth or the searched package to show only the part you want.
Notes

Notes & limitations

  • The registry is not queried

    Latest versions, vulnerabilities and licenses are not shown. Only what the lock records is used. Check vulnerabilities with `npm audit` or similar.
  • Only npm lock files are supported

    `package-lock.json` (lockfileVersion 1, 2 and 3) is supported; `yarn.lock` (classic and Berry) can be read too (`pnpm-lock.yaml` (v6 and v9) can be read too; yarn.lock records no dev-only flag, install scripts or deprecations, so those checks do not appear). For lockfileVersion 1 and yarn.lock the root's direct dependencies are inferred.
  • Large locks are drawn only in part

    When there are too many nodes, up to the limit (80) are drawn. Reduce the depth or narrow it down with a package name. The numbers (package count, duplicates, checks) are counted over the whole lock.

Articles for this tool

Recent Articles