Web & Standards

package.json (npm) JSON Example

A complete package.json JSON example for a Node.js / npm project — includes scripts, dependencies, devDependencies, engines, and metadata. Copy-ready starter for any JavaScript package.

{
  "name": "@acme/json-utils",
  "version": "1.4.0",
  "description": "Tiny utilities for parsing and transforming JSON.",
  "type": "module",
  "main": "./dist/index.js",
  "types": "./dist/index.d.ts",
  "exports": {
    ".": {
      "import": "./dist/index.js",
      "types": "./dist/index.d.ts"
    }
  },
  "scripts": {
    "build": "tsc -p tsconfig.json",
    "test": "vitest run",
    "lint": "eslint ."
  },
  "keywords": [
    "json",
    "parser",
    "utility"
  ],
  "author": "Acme Inc. <dev@acme.example>",
  "license": "MIT",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/acme/json-utils.git"
  },
  "engines": {
    "node": ">=18"
  },
  "dependencies": {
    "fast-json-stable-stringify": "^2.1.0"
  },
  "devDependencies": {
    "typescript": "^5.4.0",
    "vitest": "^1.6.0",
    "eslint": "^9.0.0"
  },
  "publishConfig": {
    "access": "public"
  }
}

Field Reference

namerequiredstringPackage name; lowercase, URL-safe, optionally scoped with @scope/
versionrequiredstringSemantic version (major.minor.patch)
typeoptionalstring'module' for ESM or 'commonjs' for CJS; controls how .js files are interpreted
exportsoptionalobjectModern entry-point map; supersedes 'main' for conditional imports
scriptsoptionalobjectNamed commands run via npm run <name>
dependenciesoptionalobjectRuntime packages with semver ranges, installed for consumers
devDependenciesoptionalobjectBuild/test-only packages, not installed by consumers
enginesoptionalobjectDeclares supported runtime versions, e.g. node >=18

Variants

Minimal appThe smallest practical package.json for a private application.
{
  "name": "my-app",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start"
  }
}

Common Use Cases

  • Bootstrapping a new npm library or Node.js application
  • Defining build, test, and lint scripts for a project
  • Pinning dependency versions and supported Node engines
package.jsonnpmnodejavascriptdependencies

Validate or format this JSON

One click loads this exact example into the tool — no copy-paste needed. Format it, validate it, explore the tree, or generate TypeScript types instantly.

Frequently Asked Questions

dependencies are needed at runtime by anyone who installs your package (e.g. a date library your code imports). devDependencies are only needed to build or test the package (e.g. TypeScript, test runners) and are skipped when someone installs your package as a dependency.

'exports' is the modern field and takes precedence in Node 12+. Keep 'main' as a fallback for older tools, but 'exports' lets you define separate ESM/CJS entry points and block deep imports into internal files.

It prevents accidental publishing to npm. Set it on applications and internal packages you never intend to publish — npm publish will refuse to run.

Related JSON Examples