Format package.json Online

Format package.json with consistent 2-space indentation. Paste your manifest to tidy scripts and dependencies before committing. Free, runs locally.

Part of the free JSON Formatter & Validator. Runs in your browser — nothing is uploaded.

Format package.json Online

npm and Yarn write package.json with 2-space indentation, so hand-edited or merged manifests that drift from this create noisy diffs. Paste yours to normalize indentation while keeping key order untouched.

Worked example: A compact manifest normalized to 2 spaces

Input (compact)

{"name":"my-app","version":"1.0.0","scripts":{"dev":"next dev","build":"next build"},"dependencies":{"next":"14.2.0","react":"18.3.1"}}

Formatted package.json

{
  "name": "my-app",
  "version": "1.0.0",
  "scripts": {
    "dev": "next dev",
    "build": "next build"
  },
  "dependencies": {
    "next": "14.2.0",
    "react": "18.3.1"
  }
}

Practical tip

Do not sort keys unless your team agrees on it. npm preserves key order, and reordering scripts or dependencies can change how a project reads.

How to use this JSON Formatter

  1. 1Use the live tool above — it runs entirely in your browser and never uploads your data.
  2. 2Paste the sample from the worked example, or use your own input.
  3. 3Copy the result, then adapt the same steps in your editor, script, or pipeline.

Format package.json Online FAQs

Which indentation does npm use for package.json?

npm writes package.json with 2 spaces and a trailing newline. Matching that avoids unnecessary diffs after npm install or npm version.

Will formatting break my package.json?

No. Only whitespace changes. If the manifest was invalid JSON to begin with, the validator will show the error instead of formatting it.

More JSON Formatter pages

Open the full JSON Formatter tool →