package.json Generator

Generates a complete, valid package.json manifest from a form: name, version, description, license, module type, Node engine constraint, npm scripts, and dependency/devDependency lists, all validated before being rendered as formatted JSON. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-26

Overview

Introduction

Every Node.js or npm-based project starts with a package.json, and getting the shape right by hand, especially the scripts and dependency blocks, is easy to get subtly wrong (a missing comma, an invalid semver, a name npm rejects on publish).

This tool builds a valid package.json from a form: fill in the package metadata, add scripts and dependencies as rows, and get back formatted, ready-to-save JSON.

What Is package.json Generator?

A form-driven generator for the package.json manifest that every Node.js/npm project requires, covering name, version, description, license, module type, Node engine constraint, npm scripts, and dependency/devDependency lists.

Every field is validated against npm's actual rules before the JSON is produced, so the output is a manifest npm and Node will accept, not just JSON that happens to parse.

How package.json Generator Works

Package name is checked against npm's naming pattern (lowercase, URL-safe characters, optional @scope/ prefix) and version against semantic versioning's MAJOR.MINOR.PATCH shape.

Scripts and dependency rows are collected into ordinary objects, empty rows are dropped, and the whole manifest is serialized with JSON.stringify(pkg, null, 2) so the resulting file matches what `npm init` would produce in formatting.

When To Use package.json Generator

Use it when bootstrapping a new Node.js or npm package and you want a correct, complete package.json without running `npm init` and then hand-editing scripts and dependencies afterward.

It's also useful for quickly assembling a manifest to paste into a new repository, a coding exercise, or a reproducible bug report.

Features

Advantages

  • Validates package name and version against npm and semver rules instead of accepting anything.
  • Repeatable rows for scripts, dependencies, and devDependencies make it fast to assemble a full manifest without typing raw JSON.
  • Output is deterministically formatted 2-space-indented JSON, matching common npm/editor conventions.

Limitations

  • Doesn't resolve dependency versions against the npm registry; version strings are taken as entered, not verified to exist.
  • Covers the common manifest fields only; advanced fields like `exports` maps, `workspaces`, or `peerDependencies` aren't included and would need manual addition.

Examples

A minimal library manifest

Input

name: my-lib, version: 1.0.0, license: MIT, type: module, script build: tsc, dependency: zod ^3.22.0

Output

{
  "name": "my-lib",
  "version": "1.0.0",
  "type": "module",
  "scripts": {
    "build": "tsc"
  },
  "dependencies": {
    "zod": "^3.22.0"
  },
  "license": "MIT"
}

Best Practices & Notes

Best Practices

  • Pin dependency versions with a caret range (^1.2.0) rather than leaving them blank/"latest", so installs stay reproducible over time.
  • Set `engines.node` to the Node version range your CI and production environment actually run, so contributors get an early warning on mismatched versions.
  • Keep `scripts` names conventional (dev, build, test, lint) so tooling and contributors can guess entry points without reading documentation.

Developer Notes

Name validation uses npm's own accepted pattern (lowercase, URL-safe characters, optional @scope/ prefix, no leading dot or underscore) and version validation checks for a MAJOR.MINOR.PATCH shape with optional pre-release/build metadata suffixes per semver 2.0.0. Empty script/dependency rows are filtered out before serialization so partially-filled form rows never leak into the output as empty-string keys.

package.json Generator Use Cases

  • Bootstrapping package.json for a new npm package or internal tool
  • Quickly assembling a manifest for a bug report or minimal reproduction repo
  • Teaching or demonstrating what a well-formed package.json looks like

Common Mistakes

  • Publishing a package name that doesn't follow npm's lowercase/URL-safe rules, which npm rejects at publish time rather than at manifest-authoring time.
  • Leaving dependency versions as "latest" in a committed manifest, which makes installs non-reproducible across machines and time.

Tips

  • Use the tsconfig Generator next if this package.json is for a TypeScript project, so the build script and tsconfig target/module settings line up.

References

Frequently Asked Questions