Introduction
package.json is the manifest of a JavaScript project or package, first
defined by npm, the package manager that comes with
Node.js. It names the package and its version, lists the packages it depends on, and
defines scripts such as build and test that are run with
npm run. Every package published to the npm registry has one, and other
JavaScript tools, from Yarn and pnpm to bundlers and test runners, read it too.
Beside it, package-lock.json (or the lock file of another package
manager) records the exact version of every package installed.
Structure
The file is a JSON object. A package to be
published needs name and version, the version following
semantic versioning. Common fields include description,
license, main or exports (the files other code
imports), type ("module" for ES modules), bin
(commands the package installs), scripts, and the
dependencies and devDependencies objects, which map package
names to version ranges such as ^4.18.0. Every field, the range syntax and
the lifecycle scripts are on the fields
page.
{
"name": "my-app",
"version": "1.0.0",
"type": "module",
"scripts": {
"start": "node server.js",
"test": "node --test"
},
"dependencies": {
"express": "^4.18.0"
}
}
Not described
The reference follows npm 11’s package.json and scripts pages, the node-semver README, Node.js “Modules: Packages”, Corepack and TypeScript’s publishing page.
Known, not yet covered
- Reference:
package-lock.json(lockfileVersion 1, 2 and 3, and the hiddennode_modules/.package-lock.json) is a separate format with its own npm documentation page. It is not covered by this page or this viewer: a lock file opens in the JSON viewer, without lock-file meaning. - Viewer: the viewer reads package.json as strict JSON (as npm does), labels
every field as an npm field or as one no reference field covers, checks each field’s
type and the rules the documentation states (names, versions, people, funding,
repository, bin and man, directories, scripts and their lifecycle, dependencies and
overrides, engines, os and cpu, devEngines, workspaces, packageManager,
typesVersions, exports and imports with their conditions), and classifies every
version spec and writes a range out as comparators. Errors and warnings carry line and
column. The
licensefield holds an SPDX licence expression, orSEE LICENSE IN <file>orUNLICENSED, according to npm’s documentation; the viewer shows it exactly as written and checks it as npm does (see the last item below), with a plain link Licenses… to SPDX’s list for looking a name up. Where the documentation gives no rule (the full set of conditions other tools define) it warns rather than reports an error. A.jsonfile is offered as a package manifest under Read as when it is namedpackage.jsonor its start looks like one, but opens in the JSON viewer. Following the documentation (docs.npmjs.com, read 2026-11-14), the viewer readspublishConfig(tag, registry and access, and labels any other config option),overrides(the"."key, a version or range in a key,$namereferences, and the EOVERRIDE rule for a direct dependency), the deprecatedlicensesarray andlicenseobject (each entry shown),files(the always-included, ignored-by-default and never-included lists, and each pattern),devEngines(its keys, theonFaildefault and what npm accepts for runtime and package manager) andmaintainers(documented as set by npm). There is no limit on the number of problems: every problem is listed (the first 500 above the tabs, the rest in pages, and all in the Problems tab), and a node with more than 25 problems holds the rest as its children. A file larger than 32 MB is read in windows by the shared JSON reader, so its text is never held and the tree and the Data tab open any part; the fields, dependencies, scripts and exports tables keep one row for each entry, about 1.5 KB for a dependency (tested on a 41 MB manifest of 190,000 dependencies: 330 MB peak resident), so a manifest of millions of entries needs memory in proportion to its entries, not to its text. It has not yet been re-checked as Full. - Viewer: a manifest of about 600 MB has not been run (the machine was loaded). Manifests of 37 MB (1,600,000 dependencies) and 74 MB (3,200,000) read through the lazy path in about 8 and 20 seconds, in memory (a synthetic source, not a file). The lazy path is covered by the JSON viewer’s own test and one case here. No browser pass of the Problems tab has been made since the latest changes.
- Viewer: where the documentation gives no rule the viewer warns and does not
report an error: a
typeother than"module"or"commonjs"(Node.js documents only those two), anexportskey with more than one*,developmentwithproductionin one object (“must be mutually exclusive” in the community conditions, which Node.js does not enforce), and anssh://dependency on a host that hosted-git-info does not know (npm stops withEUNSUPPORTEDPROTOCOL). Whether Node.js itself rejects any of these at run time is not stated in the text read. - Viewer: whether an identifier in a
licenseexpression is on the SPDX license list (or the exception list) is not checked yet: it is waiting on an owner decision about carrying the list in the site. The viewer does check everything else npm checks (normalize-package-datafixLicenseField, validate-npm-package-license and spdx-expression-parse, read from their source): a missing, empty or non-stringlicense(also read from the misspellinglicence) warnsNo license field.orlicense should be a valid SPDX license expression; the special valuesUNLICENSEDandSEE LICENSE IN <file>are accepted; the expression grammar is applied (AND,OR,WITH, parentheses, the+suffix,LicenseRef-andDocumentRef-, which npm refuses), with the parser’s reason added; and the deprecated object and array forms warn. An identifier is checked only for the shape the grammar allows (letters, digits,-and.), so an unknown, wrongly cased or misplaced identifier (for examplemit, or an exception used as a licence) passes here although npm would warn, and npm’s “license is similar to the valid expression” suggestion (spdx-correct) is not given. The viewer says so beside the licence.
Also used for
- Browser extension manifest – The JSON manifest of a browser extension: its name, permissions and scripts.
- GeoJSON – Map points, lines and areas with properties, written as JSON.
- Hugging Face model config (config.json) – config.json: a model’s architecture and sizes, read before the weights.
- Hugging Face tokenizer (tokenizer.json) – tokenizer.json: a language model’s vocabulary and tokenising rules.
- JSON Schema – A JSON document that describes and validates other JSON documents.
- JavaScript Object Notation – Text format for objects, arrays, strings, numbers and booleans.
- Lottie animation – Vector animations as JSON, exported from After Effects and played in apps and web pages.
- Visual Studio Code settings – VS Code’s settings.json: dotted setting IDs in JSON with comments.
- jCal: iCalendar in JSON – iCalendar as JSON: events, to-dos and time zones as nested arrays.
- jCard: vCard in JSON – vCard 4.0 contacts as JSON: names, numbers and addresses as arrays.
Links
Software
- npm – the package manager that defined the format (Windows, macOS, Linux)
- Node.js – the JavaScript runtime that npm comes with, which reads
type,mainandexports(Windows, macOS, Linux) - Yarn – alternative package manager (Windows, macOS, Linux)
- pnpm – alternative package manager that shares packages between projects (Windows, macOS, Linux)
- Bun – JavaScript runtime and package manager (Windows, macOS, Linux)
- Deno – JavaScript runtime that can read package.json (Windows, macOS, Linux)
Reference
- package.json – npm’s documentation of every field