How do I generate a package.json file online?
Choose a preset (Next.js, React+Vite, Node.js CLI, npm Library, Express API, Monorepo) and customize name, version, scripts, dependencies, module config, and exports. The visual builder handles ESM/CJS, bin, engines, and keywords. Download or copy the result. Everything runs in your browser.
Preset: Next.js App Name: my-app Version: 1.0.0 Private: yes
{
"name": "my-app",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"next": "^15.0.0",
"react": "^19.0.0",
"react-dom": "^19.0.0"
}
}Basic Info
Module Config
{
"name": "my-nextjs-app",
"version": "0.1.0",
"private": true,
"type": "module",
"main": "index.js",
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"next": "^15.0.0",
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"devDependencies": {
"typescript": "^5.7.0",
"@types/node": "^22.0.0",
"@types/react": "^19.0.0",
"@types/react-dom": "^19.0.0",
"eslint": "^9.0.0",
"eslint-config-next": "^15.0.0"
},
"license": "MIT"
}4
Scripts
3
Deps
6
DevDeps
Press Ctrl+Enter to copy
Tips & Best Practices
Use the exports field instead of main for modern packages
The 'exports' field in package.json provides precise control over what consumers can import. It supports conditional exports (import vs require), subpath exports, and prevents access to internal modules. It's the modern replacement for main, module, and types.
Semver ranges in dependencies can break your build unexpectedly
^1.2.3 allows any 1.x.x update, which can introduce breaking changes despite semver promises. Many packages don't follow semver strictly. Use a lockfile (package-lock.json) and review dependency updates deliberately rather than relying on automatic semver resolution.
Define scripts for the full development lifecycle
A complete scripts section includes: dev, build, start, test, lint, format, typecheck, and clean. Add pre/post hooks like prebuild for type checking. Well-defined scripts make onboarding instant — new developers just run npm run dev.
Audit install scripts — they run with full system access
npm packages can define preinstall and postinstall scripts that execute arbitrary code on `npm install`. Malicious packages have used this to steal credentials and crypto wallet keys. Use `npm audit` and review install scripts of new dependencies.