b2KIT

package.json Generator

Build package.json files with scripts, dependencies, metadata, and best-practice defaults.

Tested tool guide Tested browser tools Checked August 16, 2026

What package.json Generator does, with a checked example

This tool assembles a package.json file from form fields instead of hand-typed JSON: package name, version, description, entry point, license, author, npm scripts, and a dependency list. Each field maps directly to the matching JSON key, and fields left blank are simply omitted rather than filled with guesses. The most common surprise is dependency versions: the generator does not query the npm registry, so whatever version string you type - including the word 'latest' - is written into the file exactly as entered, with no resolution to an actual published version number.

Worked example

A concrete input and expected output from the current implementation.

Input

name: weather-cli
version: 0.1.0
description: Fetch current weather from the command line
main: bin/cli.js
license: MIT
author: Jane Doe
scripts: start = node bin/cli.js, test = echo "no tests yet"
dependencies: commander @ ^12.0.0

Expected output

{
  "name": "weather-cli",
  "version": "0.1.0",
  "description": "Fetch current weather from the command line",
  "main": "bin/cli.js",
  "scripts": {
    "start": "node bin/cli.js",
    "test": "echo \"no tests yet\""
  },
  "author": "Jane Doe",
  "license": "MIT",
  "dependencies": {
    "commander": "^12.0.0"
  }
}

Each form field writes to its corresponding top-level key; repeatable script and dependency rows become nested objects keyed by the name you typed, with the value copied through unchanged.

How the result is produced

1

Field-to-key mapping

Each form input corresponds to one package.json key: name, version, description, main, license, and author map one-to-one. Scripts and dependencies are entered as repeatable name/value rows - a script name paired with its shell command, or a package name paired with a version string - which the tool assembles into the matching nested object, preserving the text exactly as typed.

2

Structural validation

Before rendering output, the tool checks that the package name follows npm's naming rules (lowercase, no leading dot or underscore, URL-safe characters, 214-character limit) and that the version field parses as valid semver. Malformed entries are flagged for correction, but the check is purely structural - it does not confirm the name is unregistered on the npm registry.

Good uses

  • Starting a new npm package or CLI tool and needing a correctly structured package.json in one pass
  • Standardizing scripts and metadata fields across several packages in a monorepo without copy-pasting and hand-editing JSON
  • Learning or teaching which fields belong in package.json and how the scripts and dependencies objects are structured

Limits and checks

  • Dependency versions are not resolved against the npm registry - entering 'express' with version 'latest' writes the literal string 'latest' into the file, not the current published version number
  • The tool validates name format but does not check availability on npmjs.com; a structurally valid name may already be taken
  • Blank fields are omitted from the output rather than filled with Node's runtime defaults, so a missing main field won't show the implicit fallback to index.js that Node applies at require time

Common questions

Will this publish my package to npm?

No. It only generates the package.json text in your browser; nothing is uploaded or sent anywhere. You copy or download the file, place it in your project, and run npm publish yourself from the command line when you're ready.

Does it verify that my dependency names and versions actually exist on npm?

No. It doesn't query the npm registry, so it can't confirm a package name is real or that a version string corresponds to a published release. Check availability and current versions with npm view <package> or npmjs.com before relying on the generated file.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools