Paste any minified or messy JSON and instantly format it with proper indentation. Free JSON beautifier, prettifier, and validator - no signup needed.
A JSON formatter (also called JSON beautifier or JSON prettifier) converts compact, single-line JSON into a well-indented, human-readable format. When APIs return minified JSON like {"name":"John","age":30,"city":"NYC"}, a formatter turns it into:
{
"name": "John",
"age": 30,
"city": "NYC"
}
| Style | Use Case | Output |
|---|---|---|
| 2-space indent | JavaScript/Node.js standard | Most common |
| 4-space indent | Python/Java standard | More readable |
| Tab indent | Team preference | Adjustable width |
| Minified | Production / API responses | Smallest size |
| Sorted keys | Diffing / comparison | Alphabetical order |
Many developers confuse these two tools:
Free, instant, private. No account needed.
A JSON formatter does more than add whitespace — it can normalize key order, strip comments, validate structure, and prepare JSON for storage or transmission.
| Operation | Effect | Benefit |
|---|---|---|
| Indent | Adds whitespace for readability | Increases file size |
| Sort keys | Alphabetically orders object keys | Easier diff & lookup |
| Minify | Removes all whitespace | Smallest file size |
| Strip comments | Removes // and /* */ comments | Makes valid JSON |
| Normalize | Unescapes unicode \uXXXX to UTF-8 | Human-readable output |
// JavaScript — format with replacer
const formatted = JSON.stringify(obj, null, 2);
// JavaScript — sort keys
const sorted = JSON.stringify(obj,
Object.keys(obj).sort(), 2);
// Python — formatted output
import json
print(json.dumps(data, indent=2, sort_keys=True, ensure_ascii=False))
// CLI — format with jq
jq --sort-keys . input.json > output.json
Also useful: JWT Decoder | JSON to TypeScript | JSON Diff Tool | JSON Tutorials
JSON can be formatted with any indentation width, or minified entirely. The choice depends on the use case: minified for network transmission, 2-space or 4-space for human-readable config files and API responses in development.
{"user":{"name":"Alice","age":30,"roles":["admin","editor"]}}
{
"user": {
"name": "Alice",
"age": 30,
"roles": ["admin", "editor"]
}
}
{
"user": {
"name": "Alice",
"age": 30,
"roles": ["admin", "editor"]
}
}
{
"user": {
"name": "Alice",
"age": 30,
"roles": ["admin", "editor"]
}
}
Most language ecosystems have a conventional indentation style and an official formatter. Staying consistent with the ecosystem standard reduces friction when sharing code and config files with teammates.
| Ecosystem | Preferred Indent | Tool |
|---|---|---|
| JavaScript/Node.js | 2 spaces | Prettier |
| Python | 4 spaces | black, json.dumps(indent=4) |
| Java | 4 spaces | Jackson, Gson |
| Go | Tab | encoding/json MarshalIndent |
| PHP | 4 spaces | json_encode(JSON_PRETTY_PRINT) |
| Ruby | 2 spaces | JSON.pretty_generate |
| .NET/C# | 2 spaces | System.Text.Json |
| API responses | Minified | All frameworks |