Skip to content

package.json Generator

Build a valid package.json with scripts, exports and metadata.

Module system

Quick Tool Overview

The package.json Generator builds a valid manifest with the module fields set correctly — type, main and the exports map — which is where most package.json problems actually come from, and where a generator earns its place.

What it does
Generates a valid package.json
You give it
A name, a preset and your dependencies
You get back
A manifest npm and Node both read correctly
Best for
Starting a package or a published library
Developer Tools Free, unlimited use No sign-up Runs in your browser

About the package.json Generator

package.json is small enough to write by hand and structured enough to get wrong. This builds a valid one from the fields you fill in, with the script preset for your kind of project and the metadata npm actually reads.

The fields that cause the most trouble are the ones about module resolution. `\"type\": \"module\"` decides whether your .js files are ESM or CommonJS, and getting it wrong produces the "Cannot use import statement outside a module" error that has no obvious cause. For a library, the `exports` map is what lets one package serve ESM, CommonJS and TypeScript types from the same install — and it replaces `main` rather than sitting beside it, which is why this generates both correctly rather than leaving you to work out the precedence.

Key features of the package.json Generator

The exports map done properly

Types, import and require in the right order, so one package serves ESM, CommonJS and TypeScript from a single install.

Module type made explicit

The field behind "Cannot use import statement outside a module" is set deliberately rather than left to chance.

Script presets

Node, Vite, Next.js, Express, TypeScript or a published library — the scripts each of those actually needs.

Repository fields derived

Give it a GitHub path and repository, bugs and homepage are all filled in the shape npm expects.

Valid JSON, always

Built as an object and serialised, so no trailing comma or unquoted key can slip in.

How to use the package.json Generator

  1. 1

    Name and version it

    The package name, a starting version and a one-line description.

  2. 2

    Pick a script preset

    Plain Node, Vite, Next.js, Express, TypeScript or a published library.

  3. 3

    Add dependencies

    One per line as name@range — they are split into the right sections.

  4. 4

    Copy the manifest

    Save it as package.json in your project root.

Frequently asked questions

It makes every .js file in the package an ES module, so import and export work and require does not. Leave it out and the opposite is true. Files named .mjs and .cjs override it either way.

Reviews of the package.json Generator

What people who use the package.json Generator think of it. Reviews come from visitors and are posted as written.

No ratings yet

Yours would be the first.

  • 5 0 reviews rated 5 stars
  • 4 0 reviews rated 4 stars
  • 3 0 reviews rated 3 stars
  • 2 0 reviews rated 2 stars
  • 1 0 reviews rated 1 star

Write a review

Used this tool? Your rating helps the next person decide.

Your rating

Plain text only — links, email addresses and HTML are not accepted. Your name and review are shown publicly; nothing else is collected. See the privacy policy.

0 reviews

Newest first

No reviews yet

Be the first to rate the package.json Generator. It takes half a minute and no account.

Write the first review

More developer tools