DevTools Logo

package.json Linter & Analyzer

package.json Linter & Analyzer

npm-specific findings for your manifest: names, exports, dependencies, scripts and publish readiness.

Runs in your browser
Try an example

package.json

Findings

Awaiting manifest

Paste a package.json to lint it

Try the broken-manifest example to see every rule category.

Details

Generic JSON formatters cannot tell a malformed npm manifest from a valid one. This linter encodes npm naming rules (lowercase, URL-safe characters, scoped names, reserved names, 214-character limit), publish metadata expectations, exports/main resolution precedence, dependency-map mistakes (duplicates, optional conflicts, exact peer pins, irreproducible ranges), script and legacy field checks, and publish-readiness signals such as private/publishConfig conflicts. Every finding carries a severity, JSONPath-style path, rationale and fix snippet. Range validation is built in — no registry or network calls, no installed-module scanning.

More examples

Invalid name

"name": "My Package" → ERROR: must be lowercase and URL-safe

npm rejects uppercase letters and spaces in new package names.

exports vs main

"main": "./index.js" + "exports": {"./feature": ...} → WARN: exports has no "." entry

Node ignores main when exports exists, so consumers lose the root import.

Duplicate dependency

debug in dependencies and devDependencies → WARN; also in optionalDependencies → ERROR

Conflicting dependency classifications make installs hard to reason about.

Examples

Invalid name

Input
"name": "My Package"
Output
ERROR: lowercase and URL-safe required

npm rejects uppercase and spaces for new packages.

exports overrides main

Input
main: ./index.js, exports: {"./feature": ...}
Output
WARN: exports has no "." entry and overrides main

Modern Node resolution ignores main when exports is present.

Duplicate dependency

Input
debug in dependencies + devDependencies
Output
WARN with a removal suggestion

The production dependency wins; the dev entry is dead metadata.

About this tool

package.json Linter & Analyzer checks a pasted manifest against npm semantics, not just JSON syntax. It validates package names (lowercase, URL-safe, scoped names, reserved names, 214-character limit), version fields, registry metadata, entry-point consistency and dependency-map correctness.

Findings include an error, warning or info severity, a JSONPath-style location, a short rationale and a copyable fix. Entry-point checks cover exports without a "." entry, exports taking precedence over main, type: module with a .js main, and missing types declarations.

Dependency checks detect packages listed in both dependencies and devDependencies, conflicts with optionalDependencies, exact peer-dependency pins, unrecognised ranges and irreproducible latest/file/link ranges. Scripts, bin entries, legacy fields and publish-readiness flags are checked too.

The range checker is built in, so the tool is fully offline: no registry requests, no installed-module scanning and no manifest uploads.

What this tool does not do

  • No registry access, vulnerability advisory matching or installed-node_modules inspection is performed.
  • Range validation covers common semver forms and npm protocol specifiers, not every exotic edge case.
  • File existence behind bin/main/types paths cannot be verified offline.
  • Findings are advisory conventions; some private packages intentionally omit public metadata.

How to use this tool

  1. Paste a manifest

    Paste package.json into the editor or load the clean/broken example chips. Syntax errors include a line and column.

  2. Review by severity

    Filter errors, warnings and info; expand a finding for its rationale and copyable fix snippet.

  3. Fix in place

    Edit the manifest on the left — findings update immediately as you type.

  4. Export a report

    Copy or download the Markdown report to attach to a PR or publish checklist.

Use cases

First publish

Check a new package against npm conventions before npm publish.

Monorepo audits

Review each workspace manifest for inconsistent metadata and ranges.

Support triage

Diagnose install or publish failures caused by manifest mistakes.

Code review

Attach a lint report to a PR that changes package metadata.

Rule categories

CategoryChecks
NameLowercase, URL-safe, length, reserved names, scope validation
FieldsVersion, description, license, repository, author, keywords, bugs, engines
Entry pointsexports '.', main conflict, type: module, types field
DependenciesDuplicates, optional conflicts, peer pins, range validity, unpinned ranges
Scripts / publishtest script, script types, bin paths, legacy fields, private + publishConfig, files and workspaces

private: true suppresses publish-metadata findings for internal packages.

Common mistakes

Mistake:Assuming JSON validity means npm validity.

Fix:Generic validators do not know npm naming, exports precedence or dependency-map rules.

Mistake:Putting the same dependency in dependencies and devDependencies.

Fix:Keep it in dependencies only; the tool flags the duplicate.

Mistake:Pinning peerDependencies to an exact version.

Fix:Use a compatible range such as >=18 <20 to avoid consumer conflicts.

Mistake:Using latest or file: ranges for published packages.

Fix:Use a semver range so installs are reproducible.

Mistake:Expecting a vulnerability scan.

Fix:This tool checks manifest semantics only; advisories require a lockfile scanner.

Frequently asked questions

What characters are valid in an npm package name?

New names must be lowercase, URL-safe and at most 214 characters. Letters, digits, hyphens, dots and underscores are allowed; names cannot start with a dot or underscore, and reserved names such as node_modules and favicon.ico are rejected. Scoped names use @scope/name with both parts validated.

Why does exports override main?

When the exports field exists, Node's resolver consults it first and ignores main entirely. If you keep both, make sure exports has a "." entry pointing at the same file as main.

Should peerDependencies be exact versions?

Usually no. An exact pin makes conflicts likely; use a compatible range such as >=18 <20 or ^18.2.0 unless you have a specific reason to pin.

What belongs in files vs dependencies?

files is a publish allowlist of paths in your package; dependencies are runtime packages to install. When files exists, .npmignore is not used for the package contents.

Does it check my installed modules?

No. Only the pasted manifest is analyzed; there is no registry access and no node_modules scan, so no network request or local file read occurs.

Why are some findings marked info instead of warnings?

Info findings are conventional improvements (for example declaring engines or a test script), while warnings and errors describe mistakes likely to break installs or publishes.

References & standards