Browser-based lockfile analysis · the lockfile is read here, never sent

npm Lockfile Analyzer

Open package-lock.json, yarn.lock or pnpm-lock.yaml and see the dependency tree, packages installed in several versions, depth, production versus development counts, install scripts where the format records them, and every path that pulls in a given package.

Lockfile

Drop a lockfile

package-lock.json, yarn.lock or pnpm-lock.yaml, up to 25 MB

Optional: package.json (for direct dependencies in yarn.lock and lockfile v1)

Lockfile Analyzer for Duplicate Versions and Install Paths

Operator: Abdulla Al Fahad. How tools are built and checked

A security scanner flags ms@2.0.0 and you have never heard of ms. Open the lockfile here, search for it, and the page lists the shortest chains that pull it in: express > debug > ms and express > body-parser > debug > ms in the built-in example, so the fix is an upgrade of express, not something you can change directly.

The same graph answers the other questions people ask of a lockfile: which packages appear in two or more versions, how deep the tree goes, how many packages are only for development, and which ones run an install script.

package-lock.json (versions 1, 2 and 3), yarn.lock (classic and Berry) and pnpm-lock.yaml (5.x, 6.0 and 9.0) are all read into one model, so the views are the same whichever manager made the file.

Key features

  • Dependency tree you expand package by package, with depth and category badges
  • Duplicate packages: every name installed in more than one version, with how many packages depend on each
  • Depth histogram, average depth and the deepest chain
  • Production and development counts, including optional and peer dependencies
  • Install-script list for the formats that record them
  • "Why is it installed": up to 25 shortest paths from your direct dependencies
  • CSV of every package with version, category, depth, dependents and duplicate flag

What each lockfile records and what is worked out

npm lockfile versions 2 and 3 list every install location (node_modules/a/node_modules/b), with dev, optional and peer flags and hasInstallScript. Dependencies are resolved by npm's own lookup: the nearest node_modules above the dependent, walking up to the root, and workspace links are followed, and each workspace package resolves its own dependencies from its own folder before falling back to the root. Version 1 nests dependencies in a tree and records neither direct dependencies nor install scripts. Packages are counted once per name and version, and the page also reports how many folders npm would create.

yarn.lock records packages and their dependency ranges but not which are direct, which are development-only or which have install scripts. Classic files are read from their indented blocks; Berry files are read as YAML, and workspace entries supply the direct dependencies, merged across dev and production. pnpm-lock.yaml gives the importers' dependencies and devDependencies, the packages' requiresBuild flag, and for version 9 the snapshots that carry the edges (version 9 writes requiresBuild only for some packages, so a 9.0 file shows its install-script count only when at least one package carries the flag, and n/a otherwise); peer-dependency suffixes such as (react@18.2.0) are stripped so one version is one package.

Files up to 25 MB are read (YAML lockfiles up to 15 MB) and at most 150,000 packages. The Berry format is a YAML subset and the pnpm format is plain YAML, both handled by a YAML reader written for this site.

How it works

Direct dependencies are the roots of the graph; depth is the shortest distance from any root, with a direct dependency at depth 1. When the file does not name its roots (yarn.lock, Berry without workspaces, npm v1), packages that nothing depends on stand in for them, and that substitution is reported.

Adding your package.json fixes that: its dependencies, devDependencies, optionalDependencies and peerDependencies become the roots, matched to lockfile entries by yarn's range keys where they exist and otherwise to the newest version of that name, and every package is then classed as production or development by reachability.

Why-paths are found by walking backwards from the package through its dependents until a root is reached, shortest first, with chains capped at 14 packages.

When this helps

  • A reviewer looks at a pull request that grew package-lock.json by 1,200 lines, loads the old and the new file one after the other, and compares the package counts and the duplicate list to see which direct dependency brought most of them.
  • A team tries to cut install time and sorts the duplicate list: three majors of the same utility, each pulled by a different parent, show where upgrading one parent removes a whole copy.
  • A platform engineer checks a pnpm monorepo for packages with requiresBuild before enabling a policy that blocks install scripts.

Opening a file

  1. Drop the lockfile or paste its contents; for yarn.lock or an npm v1 file, open the optional box and paste package.json too.
  2. Press Analyze and read the stat cards, then the Overview, Duplicates and Install scripts tabs.
  3. Open Why installed, type a package name and pick a version to see the paths.
  4. Use the Tree tab to walk the graph, or download the CSV for a spreadsheet.
  5. Filter the CSV by the duplicate column to build a deduplication checklist.

Example

Built-in package-lock.json (lockfileVersion 3), searching for ms@2.0.0

express ^4.19.2 and lodash ^4.17.21 (prod), esbuild and jest (dev); express needs body-parser and debug 2.6.9, jest needs debug 4.3.4

Summary and the Why installed result

9 packages, 7 names, max depth 3
Duplicates: debug 2.6.9 and 4.3.4; ms 2.0.0 and 2.1.2
Install script: esbuild@0.21.5

ms@2.0.0:
express@4.19.2 > debug@2.6.9 > ms@2.0.0
express@4.19.2 > body-parser@1.20.2 > debug@2.6.9 > ms@2.0.0

Tips for best results

  • Install scripts matter most among production packages, so read the badge beside each entry: a development-only package with a script is much less of a supply-chain concern for what you ship.
  • A package with a depth of 6 or more usually has a single long chain above it; open Why installed on it and the first path shows which direct dependency owns that chain.
  • In a pnpm file, one package can appear several times with different peer suffixes; here those are merged, so the package count can be lower than the number of entries in the file.

Limits

The page reads what the lockfile says, not what is on disk. A lockfile can be out of step with package.json or with node_modules, and nothing here checks that.

A pnpm 9.0 lockfile that lists no requiresBuild flag at all shows n/a for install scripts. That is not a clean bill of health: pnpm 9 leaves the flag out for most packages, so check with pnpm itself before relying on a count of zero.

yarn.lock and npm v1 files contain no install-script information, and without package.json no production or development split, so those cards show n/a instead of a guess.

Duplicates are counted by name only. Two versions that differ in the patch number count as a duplicate even though deduplication may be blocked by an exact range, so treat the list as candidates.

Common errors and how to fix them

"This looks like package.json, not a lockfile"
A lockfile has lockfileVersion (npm), a __metadata block (Berry) or lockfileVersion with importers and packages (pnpm). Open package-lock.json, yarn.lock or pnpm-lock.yaml, and use package.json only in the optional box.
"This text doesn't look like a package-lock.json, yarn.lock or pnpm-lock.yaml."
The text parsed as YAML but is not a mapping, so it is probably a log, a README or a pasted list. Open the lockfile itself; a plain package list has none of the keys the three formats use.
"The YAML's aliases expand to more than 1,000,000 values"
A YAML lockfile uses aliases (&a and *a) that refer to other aliases many times over. Real lockfiles do not, so the file is refused before it is converted; check whether it was generated or edited by hand.
"pnpm lockfileVersion 4.0 is not supported. This page reads 5.x, 6.0 and 9.0."
Other versions are refused rather than guessed. Regenerate the lockfile with a current package manager, or open a version this page reads.

Best practices

  • Compare duplicate lists before and after a dependency upgrade: the number of names with two or more versions is a quick measure of whether the upgrade made the tree wider.
  • When you add package.json, use the one that sits next to that lockfile; a different file silently drops the dependencies it does not list.

Frequently asked questions

Why does the package count differ from npm ls?

The page counts one package per name and version, while npm creates a folder for every place the same version is nested. The Overview tab shows the folder count too when it differs, so both numbers are on screen.

Why is a package at depth 1 also shown deeper in the tree?

Depth is the shortest path, but the tree shows every parent. A package that is both a direct dependency and a dependency of another package appears at depth 1 and again under that parent.