The example
The JSON above is the example. Explore it in the Tree tab, press Download to save it as a .json file, or Share to send someone a link to it. All names, ids, emails and values are invented.
Fields explained
| Path | Type | Notes |
|---|---|---|
name / version | string | The package identity. Version numbers follow semantic versioning: major.minor.patch. |
private | boolean | true prevents accidentally publishing the package to npm. |
scripts | object | Named commands you run with npm run <name>. |
dependencies | object | Packages needed at runtime. The ^ prefix allows compatible minor and patch updates. |
devDependencies | object | Tools needed only for development and builds. |
engines | object | Which Node.js versions the project supports. |
Read it in code
JavaScript:
import pkg from "./package.json" with { type: "json" };
console.log(pkg.version);Python:
import json
version = json.load(open("package.json"))["version"]What this example is good for
- Understanding what each field does
- A starting point for a new project
- Practising edits in the tree view
Tips
- package.json must be strict JSON: no comments and no trailing commas, unlike tsconfig.json.
- Commit the lockfile as well; it pins the exact versions that ranges like ^19.0.0 resolve to.
Convert this example
Open it in a converter, then switch the output in the Code tab:
- JSON to TypeScript
- JSON to Zod
- JSON to Python (Pydantic)
- JSON to Go
- JSON to JSON Schema
- JSON to CSV
- JSON to YAML
- JSON to XML