package.json Generator
A package.json is easy to write and easy to write wrongly: a name with a capital letter in it, a version that is not semver, a dependency range npm cannot parse. This generates a complete manifest — name, version, type, entry point, scripts, dependencies and licence — then parses the JSON back and checks each field against npm's own grammars rather than against what looks about right.
What this generator does
Builds a manifest as data, serialises it as formatted JSON, parses that text back and compares it with the original. It then checks npm's rules: the package name against npm's name grammar, the version against semver, every dependency range against the caret, tilde and exact forms, and every script against being empty.
How to use this tool
- Generate a manifest.
- Read the scripts and dependency ranges.
- Check the verification note under the file.
- Copy it as a starting point, or as a fixture for something that reads manifests.
Understanding the controls
- Generate
- Draws a fresh package name, version, licence and set of dependencies. The scripts block stays consistent because those four commands are what nearly every project needs.
Common use cases
- Starting a small project without copying a manifest from another one
- Producing fixtures for a tool that parses package.json files
- Showing what a caret range and a tilde range look like side by side
- Teaching the difference between dependencies and devDependencies
- Getting a scripts block with the four commands most projects need
How this generator works
The version is assembled from three numbers rather than a template, so it is a real semantic version rather than a plausible-looking string, and it is tested against the semver grammar afterwards. Dependency ranges use the caret form npm writes by default. The manifest is marked private, which is npm's own guard against publishing something by accident — a sample manifest is exactly the kind of file that ends up in a real project.
Randomness and fairness
Name, version numbers, licence and the choice of dependencies are drawn with the browser's cryptographic random source, so running it again gives a genuinely different manifest.
For how randomness is produced across the whole site, see how Generate Random works.
Limitations and good to know
- Scoped names like @org/package are not generated, though npm accepts them.
- The dependency list is a small built-in set of well-known packages rather than a live search of npm, and the versions are examples rather than the current ones.
- Fields a published package needs — repository, author, files, exports — are not included, because this is a starting point rather than a release manifest.
- The check confirms the manifest is well-formed, not that the dependencies resolve or that the versions still exist.
Privacy and your data
The manifest is generated in your browser from built-in values. You enter nothing, nothing is uploaded or stored, and analytics records only that the tool ran.
Related generators
- Docker Compose File GeneratorA sample docker-compose.yml with an app service, a data store, a volume and a network — parsed back and checked before you see it.
- Kubernetes Manifest GeneratorA sample Deployment, Service or ConfigMap with the required keys present, the names legal and the labels actually matching.
- Semantic Version GeneratorA semantic-version-shaped string (MAJOR.MINOR.PATCH).
- JSON Sample GeneratorGenerate a small sample JSON object with randomised placeholder values, for API mockups.