How Do I Prettify JSON Online?
Paste your minified JSON below to format it with proper indentation. JSON.stringify(obj, null, 2) adds 2-space indentation. Common issues: trailing commas (invalid in JSON), single quotes (must be double), comments (not allowed).
How to Prettify JSON
In JavaScript, prettifying JSON is a one-liner:
// From a string:
const pretty = JSON.stringify(JSON.parse(minifiedString), null, 2);
// From an object:
const pretty = JSON.stringify(myObject, null, 2);
The third argument (2) controls indentation. Use 2 for 2-space indent, 4 for 4-space, or "\t" for tabs.
Before and After
Minified:
{"users":[{"id":1,"name":"Alice","email":"alice@example.com"},{"id":2,"name":"Bob","email":"bob@example.com"}]}
Prettified:
{
"users": [
{
"id": 1,
"name": "Alice",
"email": "alice@example.com"
},
{
"id": 2,
"name": "Bob",
"email": "bob@example.com"
}
]
}
Common JSON Errors
| Error | Invalid | Valid |
|---|---|---|
| Trailing comma | {"a": 1,} |
{"a": 1} |
| Single quotes | {'a': 'b'} |
{"a": "b"} |
| Comments | {"a": 1 // note} |
{"a": 1} |
| Unquoted keys | {a: 1} |
{"a": 1} |
Command-Line Prettify
# Python (built-in)
echo '{"a":1,"b":2}' | python3 -m json.tool
# jq (install: brew install jq)
echo '{"a":1,"b":2}' | jq .
# Node.js
node -e "console.log(JSON.stringify(JSON.parse(require('fs').readFileSync('/dev/stdin','utf8')),null,2))"
Use the Kappafy JSON explorer to paste, prettify, explore as a tree, see JSONPath for any node, and generate mock API endpoints from your JSON structure.