Package.json Generator
Generate a package.json file with common configurations
{
"name": "my-package",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"start": "node index.js",
"dev": "node --watch index.js",
"test": "echo \"Error: no test specified\" && exit 1",
"build": "echo \"No build step configured\""
},
"keywords": [],
"author": "",
"license": "MIT"
}About This Tool
Fill in name, version, description, entry point, and license, optionally add scripts, dependencies, and devDependencies, and the generator emits a clean package.json that npm and pnpm both accept. The schema follows the official npm field reference and skips fields you didn't provide.
Pick a license from the SPDX dropdown rather than typing a custom string — registries and license-checkers expect SPDX identifiers (MIT, ISC, Apache-2.0, UNLICENSED). 'Custom' license strings make legal automation cranky.
The scripts section is where you'll spend most of your time. Common starters are included: build, dev, test, lint, format. Add or remove them before copying the output.
What the generator emits and why each field matters: name (must be lowercase, URL-safe — controls the npm install identifier and import path). version (semver string — registries reject anything else). main (legacy CJS entry point). exports (modern, subpath-aware entry point with conditional ESM/CJS). type (module = ESM by default, commonjs = CJS by default). engines (Node version constraint). files (allowlist for what gets published — beats relying on .npmignore). repository, bugs, homepage (metadata that surfaces on npmjs.com and in IDE tooltips).
Worked example: a small utility library called 'tiny-debounce.' Generator output: { "name": "tiny-debounce", "version": "1.0.0", "description": "Minimal debounce utility, zero deps", "type": "module", "main": "./dist/index.cjs", "module": "./dist/index.mjs", "exports": { ".": { "import": "./dist/index.mjs", "require": "./dist/index.cjs" } }, "files": ["dist"], "scripts": { "build": "tsup src/index.ts --format esm,cjs --dts", "test": "vitest run" }, "license": "MIT" } The exports field gives you dual-format publishing; the files allowlist keeps source out of the published tarball; type: module makes raw .js ES modules.
Mistakes the generator can't catch: forgetting to publish before incrementing version (npmjs.com rejects re-uploads of the same version even after unpublish). Setting a version with v prefix (1.0.0 yes; v1.0.0 no — npm rejects it). Naming conflicts (npm now reserves names that previously existed even after unpublish, so name-squatting is a real risk for new releases). Run npm publish --dry-run before the real publish to catch most of these.
Common generator outputs by project type: a CLI tool wants bin field pointing to your executable plus a preferBin: true. A library wants exports field with import/require/types conditions. A monorepo workspace package wants private: true and workspaces field at the root. A web app wants nothing special beyond scripts. The generator picks defaults based on the project type you select; check the output to confirm it matches your intent.
The about text and FAQ on this page were drafted with AI assistance and reviewed by a member of the Coherence Daddy team before publishing. See our Content Policy for editorial standards.