package.json generator
Generate a package.json with name, version, type, license, engines, files and scripts, plus automatic scripts and dev dependencies for TypeScript, ESLint, Prettier, Vitest and Playwright, with dependencies sorted by name.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
Project details
Toolchain
Ticking a tool adds its scripts and dev dependency; a version you typed yourself wins.
Dependencies
Preview
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"type": "module",
"license": "MIT",
"engines": {
"node": ">=20.0.0"
},
"files": [
"dist"
],
"scripts": {
"start": "node dist/index.js",
"dev": "node --watch src/index.ts",
"build": "tsc -p tsconfig.json",
"typecheck": "tsc --noEmit",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"format": "prettier --write .",
"format:check": "prettier --check ."
},
"dependencies": {
"zod": "^3.23.8"
},
"devDependencies": {
"@types/node": "^22.9.0",
"eslint": "^9.15.0",
"prettier": "^3.3.3",
"typescript": "^5.6.3"
}
}
The output is valid JSON with 2-space indentation: fixed field order, dependencies sorted by name, ready for npm install.
What this tool does
- Bootstrap a new project with a package.json whose engines, files and type fields are already correct, without re-reading the docs.
- Prepare a library for publishing: set private, files and license once and avoid shipping sources or tests to npm by accident.
- Tick TypeScript, ESLint, Prettier, Vitest and Playwright to get the matching scripts and dev dependencies instead of hand-writing test:watch or format:check.
- Audit an inherited repository against the generated file to check field order, dependency versions and script naming.
Example
Input
Package name my-app, version 0.1.0, ESM, private package; TypeScript and Vitest ticked; runtime dependency zod@^3.23.8
Output
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"type": "module",
"license": "MIT",
"engines": {
"node": ">=20.0.0"
},
"files": [
"dist"
],
"scripts": {
"start": "node dist/index.js",
"dev": "node --watch src/index.ts",
"build": "tsc -p tsconfig.json",
"typecheck": "tsc --noEmit",
"test": "vitest run",
"test:watch": "vitest"
},
"dependencies": {
"zod": "^3.23.8"
},
"devDependencies": {
"@types/node": "^22.9.0",
"typescript": "^5.6.3",
"vitest": "^2.1.5"
}
}
With TypeScript the files field defaults to dist and the dev script points at the .ts source; Vitest adds test and test:watch scripts plus the vitest and @types/node dependencies.
Frequently asked questions
How do I write dependencies?
Use name@range, one per line, for example zod@^3.23.8 or @types/node@^22.9.0. Names must be lowercase and scoped packages look like @scope/name@range. A malformed entry is reported instead of producing a package.json that cannot install.
Can I keep my own versions when a toolchain is ticked?
Yes. The generator only adds its default version when no dev dependency with that name exists, so writing vitest@^3.0.0 yourself overrides the built-in ^2.1.5. The same package cannot be both a dependency and a dev dependency, so pick one.
Should private stay on?
Internal projects, applications and scaffolds should keep private: true — it is the last guard against an accidental npm publish. Turn it off when you really publish a public library, and make sure files only contains build output such as dist.
What does engines.node actually do?
engines is a declaration: npm does not refuse to install on a mismatched version unless engine-strict is set, but pnpm, yarn and most CI systems warn or block on it, and it documents the requirement for collaborators. The default here is >=20.0.0.
Is the generated JSON always parseable by npm?
Yes. The output is plain JSON with 2-space indentation, no comments and no trailing commas; field order is fixed, dependencies are sorted by name, and both the package name and version are validated against npm rules, so you can save it and run npm install directly.
Keywords:package.jsonpackage.json generatorpackage.json 模板npm initnpm scriptsengines nodedevDependenciesdependenciesnode 项目前端工程化typescript 依赖vitest 脚本