🛠️DevTools

Format package.json

Format your package.json files for better readability when editing dependencies and scripts.

Indent:
Switch tool:
Try:
Valid JSON
137 characters
Click nodes to toggle
{
"name": "my-app",
"version": "1.0.0",
"dependencies": {
"react": "^18.0.0",
"next": "^14.0.0"
},
"scripts": {
"dev": "next dev",
"build": "next build"
}
}

How it works

  • Paste your JSON — it validates and formats automatically
  • Invalid JSON shows error details with line/column position
  • Choose 2 or 4 space indentation
  • Copy or download the formatted result

Code Examples

Here's how to achieve this in different programming languages:

1// Format JSON with 2-space indentation
2const input = `{"name":"my-app","version":"1.0.0","dependencies":{"react":"^18.0.0","next":"^14.0.0"},"scripts":{"dev":"next dev","build":"next build"}}`;
3const formatted = JSON.stringify(JSON.parse(input), null, 2);
4console.log(formatted);
5
6// Output:
7// {
8// "name": "my-app",
9// "version": "1.0.0",
10// "dependencies": {
11// "react": "^18.0.0",
12// "next": "^14.0.0"
13// },
14// "scripts": {
15// "dev": "next dev",
16// "build": "next build"
17// }
18// }

More JSON Examples

Related JSON Tools

📚 Learn More