package.json Generator and Validator

Fill in a form to get a clean package.json for a library, CLI or app, or paste yours to see errors, warnings and tips before you publish to npm.

브라우저에서 실행됩니다. 파일은 기기 밖으로 나가지 않습니다. 확인하는 방법 보기

…

사용 방법

  1. 1
    Choose a mode

    Use Build package.json to start from a form, or Check an existing file to open or paste one.

  2. 2
    Fill in the basics

    Enter name, version, licence, description, author and links; the repository is normalised to the git+https form.

  3. 3
    Set entry points

    Pick the module type, main and types, then apply an exports preset and edit it as JSON.

  4. 4
    Add scripts and commands

    Start from a script preset or add your own rows, and list any bin commands for a CLI.

  5. 5
    Add dependencies

    Paste name@range lines in bulk, choose the group, and fix anything the checks flag.

  6. 6
    Download

    Copy package.json or download it, after the checks panel shows no errors.

이 도구 소개

package.json looks simple, yet small mistakes in it cause some of the most confusing problems in the JavaScript ecosystem: a package that installs but cannot be imported, TypeScript that cannot find the types, a CLI that does nothing, or a publish that npm rejects. This tool has two halves. The builder is a form with every field most projects need: name, version, description, author, keywords, license, repository, homepage and bugs; type, main, module and types; an exports editor with presets for dual ESM and CommonJS, ESM only, CommonJS only and subpath patterns; scripts with presets for a TypeScript library, a Node CLI, a Vite app and a Next.js app; bin commands; files, sideEffects, engines, packageManager and publishConfig; and four dependency groups with a bulk box where you paste name@range lines. The JSON is written in the conventional field order with dependencies sorted alphabetically, exactly as npm itself would write them. The checker runs on the built file and on any package.json you open or paste. It applies the npm package name rules (lowercase, URL-safe, 214 characters, no leading dot or underscore, no Node core module names, correct scope syntax), validates the version as semver 2.0, parses every dependency range, recognises workspace, file, git, npm alias and URL specifiers, and checks the exports map: targets must start with ./, types must come first, default must come last, and subpaths cannot be mixed with conditions. It also flags install scripts, deprecated prepublish, shell-only commands, wide-open ranges, local paths in published packages, packages listed twice, and tools that belong in devDependencies.

Errors, warnings and tips

Errors are problems npm, Node.js or TypeScript will act on: an invalid name or version, an exports target without ./ or an engines range that does not parse. Warnings are legal but risky, such as a dependency on * or a deprecated SPDX licence id. Tips point out conventions, for example that a library without a files list publishes its tests too.

The exports field in practice

Once exports is present, Node.js only lets people import the paths listed in it, so remember ./package.json if tools read it. Conditions are matched from top to bottom and the first match wins, which is why types must be first and default last. A dual package needs separate files for import and require, usually .js and .cjs when type is module.

Loading an existing file

Load into the form copies the known fields into the builder so you can fix them with undo and redo. Fields the form does not cover, such as workspaces, overrides or browserslist, are listed so you can add them back by hand.

Limits

Versions are not looked up on the npm registry, so the tool cannot tell whether a version exists or is the latest; it only checks that the range is valid. It is not a replacement for npm publish --dry-run, which also shows the exact file list.

풀이 예시

A pasted file has the name My-Utils, version 1.0, license GPL-3.0, type esm, typescript and eslint in dependencies, lodash in both dependencies and devDependencies, a postinstall script and engines.node set to sixteen. The checker reports 4 errors (name must be lowercase, version is not semver, type must be module or commonjs, engines.node is not a range), 3 warnings (deprecated GPL-3.0 id, install script, lodash listed twice) and tips to move typescript and eslint to devDependencies. After Load into the form and five edits, the rebuilt file has 0 errors.

한눈에 보기

자주 묻는 질문

Can it create a package.json for an app that is never published?

Yes. Tick private and the checker relaxes the rules that only matter for publishing, such as a required name, version and licence, and it stops warning about local file: dependencies.

Which licence should I pick?

MIT and ISC are the most common permissive choices for JavaScript libraries, and Apache-2.0 adds an explicit patent grant. Use UNLICENSED for private code you do not want others to use. For GPL licences the SPDX ids now end in -only or -or-later.

Does it check that dependency versions exist?

No. Nothing is sent to the npm registry. The checker validates the syntax of each range and flags risky ones such as *, latest and empty strings, but it cannot tell you whether 4.17.99 was ever published.

Why does the order of conditions in exports matter?

Node.js and bundlers walk the conditions in the order written and use the first one that applies. If default comes before import, the import line is never reached, and TypeScript only reads types when it appears before the other conditions.

What does the files field do?

It is an allow-list of files and folders included when you run npm publish. package.json, README and LICENSE are always included. Without files, everything not excluded by .npmignore or .gitignore is published, which often includes tests and source maps.

Is my package.json uploaded?

No. The form, the checks and the file you open stay in your browser. The draft is saved in this browser's local storage so you can come back to it.

완전 무료요금 없음, 가입 없음
파일은 비공개로 유지됩니다모든 작업이 브라우저 안에서 이루어집니다
내 언어로 쉽게여러 언어로 제공