package.json Generator

Generate a package.json with React, Next.js, Express, testing, Tailwind, and Prisma presets. Live JSON preview, copy or download. Free and in-browser.

Advertisement

Free package.json Generator with Framework Presets

A package.json file is the manifest at the root of every Node.js and npm project. It names the package, pins its dependencies, defines the scripts your team runs a hundred times a day, and tells Node whether to treat your code as ESM or CommonJS. This generator builds one field by field, shows the resulting JSON live as you type, and lets you copy or download the finished file. Everything runs in your browser — no registry calls, no account, nothing uploaded.

It is aimed at three situations: starting a project without running npm init and then editing the result, assembling a manifest for a stack you set up rarely enough that you have to look up the dependency names, and checking the exact shape of a field you half-remember. Fourteen presets — React, Next.js, Express, a Node CLI, a testing stack, Tailwind CSS, Prisma, authentication, UI components, forms, state management, linting and formatting, and a Turborepo monorepo — each merge in their dependencies and scripts without wiping what you already added.

How to Use the Generator

  1. Fill in the basics. Package name, version, description, entry point, license, author, repository, keywords, and the minimum Node version.
  2. Choose module type and privacy. module for ESM or commonjs for require(). Leave private on for anything you are not publishing to npm.
  3. Apply presets. Open the Presets tab and click any combination. Presets merge: applying React and then Testing Stack and then Linting gives you all three sets of dependencies and scripts, and duplicate entries are skipped rather than added twice.
  4. Add anything missing by hand. Dependencies take a name and a version range and a dev/production toggle; scripts take a name and a command.
  5. Copy or download. The output pane shows formatted JSON with two-space indentation. Copy it, or download it directly as package.json.

Two details of the output are worth knowing. Dependencies and devDependencies are sorted alphabetically, which is what npm itself does and what keeps diffs readable. Empty fields are omitted entirely rather than written as empty strings, so you get a clean manifest rather than one padded with blanks.

package.json Field Reference

FieldExampleWhat it controls
name"my-app"Package identifier. Lowercase, no spaces, max 214 characters, cannot start with . or _. Scoped form is @scope/name.
version"1.0.0"Semantic version: MAJOR.MINOR.PATCH. Required for publishing.
description"An API server"One-line summary shown on the npm registry page and in search results.
privatetrueBlocks accidental npm publish. Set it on every application and internal package.
type"module"module makes .js files ESM; commonjs (the default) makes them CommonJS.
main"dist/index.js"Entry point resolved when something imports your package by name.
types"dist/index.d.ts"TypeScript declaration entry point. The generator only emits it when TypeScript or an @types/ package is present.
license"MIT"SPDX identifier. The generator offers MIT, Apache-2.0, GPL-3.0, BSD-3-Clause, ISC, UNLICENSED, and proprietary.
author"Jane Doe"Free-form author string.
repository{"type":"git","url":"..."}Source location. A URL becomes the object form automatically; a shorthand such as user/repo stays a plain string.
keywords["api","express"]Registry search terms. Only meaningful for published packages.
engines{"node":">=18.0.0"}Declares the Node versions the package supports. npm warns on mismatch; some CI systems and hosts enforce it.
scripts{"dev":"next dev"}Named commands run with npm run <name>. Locally-installed binaries are on PATH inside a script.
dependencies{"react":"^19.0.0"}Packages needed at runtime. Installed for consumers of your package.
devDependencies{"vitest":"^2.0.0"}Packages needed only to build and test. Skipped by npm install --production.

Version Range Syntax

The version string next to each dependency is a range, not a fixed version, and misreading it is one of the most common sources of surprise upgrades. The Reference tab in the tool lists these; here they are with worked bounds:

RangeMatchesDoes not match
^1.2.31.2.3 up to but excluding 2.0.0 — any minor or patch release2.0.0
~1.2.31.2.3 up to but excluding 1.3.0 — patch releases only1.3.0
1.2.3Exactly 1.2.31.2.4
>=1.2.31.2.3 and anything above it, including major bumps1.2.2
*Any published version
latestWhatever is currently tagged latest on the registry

The caret is npm’s default because semantic versioning promises that minor and patch releases are backwards compatible. That promise is not enforced by anything, which is why a lockfile matters: the range in package.json describes what you accept, while package-lock.json records what you actually installed. Commit both. If you need to reason about which range a specific version satisfies, the semver calculator evaluates the comparison directly.

One special case catches people out: for versions below 1.0.0, the caret is much stricter than it looks. ^0.2.3 allows 0.2.x but not 0.3.0, because pre-1.0 packages are assumed to break on every minor bump.

ESM versus CommonJS

The type field decides how Node interprets a .js file. With "type": "module" you write import pkg from 'package' and top-level await works; with "type": "commonjs" or the field omitted, you write const pkg = require('package'). The extensions .mjs and .cjs override the field on a per-file basis, which is the usual escape hatch when a project has to contain both.

The practical consequence: an ESM package cannot be loaded with require() from CommonJS code without a dynamic import(). Publishing a library that a mixed audience can consume means either shipping both builds and describing them through an exports map, or picking one and stating it clearly.

Scripts Worth Standardising On

Consistent script names across repositories mean a new contributor never has to read the manifest to find out how to start the project. The conventional set is dev for the development server, build for a production build, start to run that build, test for the test suite, lint for the linter, format for the formatter, and typecheck for a no-emit TypeScript pass. The presets in this generator use exactly those names.

Two npm behaviours are worth remembering. npm test and npm start work without the run keyword, while everything else needs npm run <name>. And pre and post prefixes still fire automatically — a prebuild script runs before build without any wiring.

Frequently Asked Questions

Does this replace npm init?

It covers the same ground with a visual form and adds framework presets, but the two are complementary. npm init -y is faster if you want a stub to edit; this generator is faster when you want a complete manifest with the right dependencies already listed and correctly split between production and dev.

Are the dependency versions in the presets current?

The presets carry version ranges that were reasonable when they were written, and they are starting points, not a live registry feed. Run npm outdated after installing, and check release notes before accepting a major bump.

What is the difference between dependencies and devDependencies?

Dependencies are needed for the code to run and are installed for anyone who installs your package. devDependencies are only needed to build, test, or lint, and are skipped by production installs. Bundlers, test runners, linters, and type definitions belong in devDependencies; a web framework your server imports at runtime does not.

Why did the types field not appear in my output?

The generator only emits types when your dependency list includes typescript or a package starting with @types/. Pointing at a declaration file that a JavaScript-only project never produces would just be misleading, so the field is omitted.

Should I set private: true?

Yes, for every application and every internal package. It makes npm publish refuse to run, which is a cheap guard against publishing proprietary code to the public registry by accident. Turn it off only when you genuinely intend to publish.

What does the engines field actually enforce?

By default, npm prints a warning on mismatch and installs anyway. It becomes an error if engine-strict=true is set in .npmrc. Many hosting platforms and CI images read it to pick a Node version, which is the main reason to keep it accurate.

Can I use the output with pnpm or Yarn?

Yes. The manifest format is shared across npm, pnpm, Yarn, and Bun. Only the lockfile differs, and each tool generates its own on first install. Workspace configuration syntax differs slightly between package managers, so check that field if you are building a monorepo.

Is the file I build sent anywhere?

No. The whole generator is client-side JavaScript. The JSON is assembled in your browser, and the copy and download actions use your own clipboard and filesystem. Nothing reaches a server.

What should I do next after generating the file?

Save it as package.json, run npm install, then add a .gitignore with the .gitignore generator so node_modules and your .env stay out of version control, and create that .env with the .env file generator.

What Is package.json

package.json is the manifest file for Node.js projects and npm (Node Package Manager) packages. It defines the project's name, version, dependencies, scripts, entry points, and metadata. Every Node.js project — from simple scripts to complex web applications — starts with a package.json file.

This tool generates properly structured package.json files with common configurations for various project types, saving setup time and ensuring best practices are followed from the start.

Key Fields

FieldRequiredPurposeExample
nameYesPackage identifier (lowercase, no spaces)"my-api-server"
versionYesSemantic version"1.0.0"
descriptionNoBrief package description"REST API for user management"
mainNoEntry point for CommonJS"dist/index.js"
moduleNoEntry point for ES modules"dist/index.mjs"
scriptsNoNamed command shortcuts{"start": "node server.js"}
dependenciesNoProduction packages{"express": "^4.18.0"}
devDependenciesNoDevelopment-only packages{"jest": "^29.0.0"}
enginesNoRequired Node.js/npm versions{"node": ">=20.0.0"}
licenseNoLicense identifier"MIT"
typeNoModule system ("module" or "commonjs")"module"

Common Use Cases

  • New project scaffolding: Generate a complete package.json with appropriate scripts, dependencies, and configuration for your project type (API, CLI, library, web app)
  • Library publishing: Create package.json with correct fields for publishing to npm, including exports, files, keywords, and repository metadata
  • Monorepo workspace setup: Generate root and workspace package.json files for monorepo tools like npm workspaces, Turborepo, or Lerna
  • Migration projects: Convert existing projects to new module systems (CommonJS to ESM) with correct type and exports fields
  • CI/CD configuration: Define scripts for testing, building, linting, and deployment that CI/CD pipelines will execute

Best Practices

  1. Pin exact dependency versions for applications — Use exact versions (no ^ or ~) in application projects to ensure reproducible builds. Use lock files (package-lock.json) and commit them.
  2. Use ranges for library dependencies — Libraries should use ^ ranges to allow consumers to resolve compatible versions without conflicts.
  3. Define an engines field — Specify the minimum Node.js version your project requires. This prevents cryptic runtime errors when users run your code on unsupported versions.
  4. Keep scripts organized — Define standard scripts: start, build, test, lint, dev. Use pre/post hooks (pretest, postbuild) for ordered workflow steps.
  5. Set "type": "module" for new projects — ES modules are the standard. New projects should default to ESM unless they need CommonJS compatibility.
  6. Use the files field for packages — When publishing to npm, use the files array to specify exactly which files to include. This keeps your package small and avoids leaking unintended files.

Frequently Asked Questions

What is the difference between dependencies and devDependencies?+

dependencies are required to run your application in production. devDependencies are only needed during development (testing, building, linting). When deploying, you can skip devDependencies with npm install --production.

Should I use type: module or type: commonjs?+

Use type module for ESM (import/export syntax) - recommended for new projects. Use type commonjs for traditional Node.js (require/module.exports). ESM is the modern standard with better tree-shaking and static analysis.

What version ranges should I use: ^, ~, or exact?+

^ (caret) allows minor and patch updates: ^1.2.3 matches 1.x.x. ~ (tilde) allows only patch updates: ~1.2.3 matches 1.2.x. Exact versions (1.2.3) never auto-update. Use ^ for most packages, exact versions for critical dependencies.

What are common npm scripts I should include?+

Essential scripts: dev (development server), build (production build), start (run production), test (run tests), lint (run linter). Also consider: typecheck, format, preview, db:migrate for database projects.

This tool is provided for informational and educational purposes only. All processing happens in your browser — no data is sent to or stored on our servers. While we strive for accuracy, we make no warranties about the completeness or reliability of results.