package.json Generator
Generate a clean package.json from a small form.
Overview
Fill in name, version, description, author, license, entry points, scripts, and optionally pick from a list of common dependencies - the generator emits a clean package.json that's ready to commit. No npm init interrogation, no leftover boilerplate.
It's for JavaScript and TypeScript developers bootstrapping new packages, especially libraries and CLI tools where the package.json shape matters more than for a one-off app. Reach for it when starting a new monorepo workspace, scaffolding a published-to-npm library, or normalising an existing package.json that's accumulated cruft.
How it works
The output follows the package.json fields documented in the npm CLI documentation - the canonical reference for what npm, yarn, and pnpm all read. Required-by-convention fields (name, version) are always emitted; optional ones (exports, types, engines, repository, bugs) appear only when filled in.
Names are validated against npm's rules: lowercase, no spaces, no special characters beyond - and _, max 214 characters, optionally scoped (@scope/name). The default version follows SemVer 2.0.0.
Examples
- Minimal library package:
{ "name": "my-lib", "version": "0.1.0", "description": "A small library", "main": "dist/index.js", "license": "MIT" } - TypeScript library with modern exports:
{ "name": "@me/lib", "version": "1.0.0", "type": "module", "exports": { ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" } }, "files": ["dist"] } - CLI tool:
{ "name": "my-cli", "version": "1.0.0", "bin": {"my-cli": "./bin/cli.js"} } - Engines lock:
{ "engines": {"node": ">=20"} }
FAQ
Should I set "type": "module"?
Yes if you're publishing modern ESM. CommonJS is still common, and you can support both via the exports field's conditional entries.
What's the difference between main and exports?
main is the legacy single-entry pointer. exports is the modern, conditional-aware way to declare entry points - the official recommendation since Node 14. Set both for maximum compatibility.
Why include files?
The files field whitelists what gets published to npm. Without it, npm publishes everything not in .npmignore or .gitignore. Be explicit to avoid leaking source maps, tests, or secrets.
Do I need repository?
Not required, but populating it gives npm pages, GitHub, and tools like npm bug something to link to. Include the URL even for private packages.