JSON Pretty Print: Format and Beautify JSON Data
Minified JSON is compact and efficient for machines, but it's nearly impossible to read when you're debugging or reviewing data. Pretty printing adds consistent indentation and newlines to transform a single compressed line into a human-readable structure.
What Pretty Print Does
{"user":{"id":1,"name":"Alice","roles":["admin","editor"]}}{
"user": {
"id": 1,
"name": "Alice",
"roles": [
"admin",
"editor"
]
}
}Pretty Print Online (Fastest)
The quickest method requires zero code. Paste your JSON into our JSON Pretty Print tool, choose your indent size (2 or 4 spaces), and press Ctrl+S. The formatted output appears instantly — fully client-side, so your data never leaves the browser.
Pretty Print with JavaScript / TypeScript
const data = { user: { id: 1, name: 'Alice', roles: ['admin', 'editor'] } };
// The third argument controls indent (number = spaces, string = custom)
console.log(JSON.stringify(data, null, 2)); // 2-space indent
console.log(JSON.stringify(data, null, 4)); // 4-space indent
console.log(JSON.stringify(data, null, '\t')); // tab indentPretty Print with Python
import json
data = {"user": {"id": 1, "name": "Alice", "roles": ["admin", "editor"]}}
# indent=2 for 2-space indentation
print(json.dumps(data, indent=2))
# Reading from a file and pretty-printing
with open('data.json') as f:
obj = json.load(f)
print(json.dumps(obj, indent=2, sort_keys=True))Pretty Print from the Command Line
# Python built-in (no install)
cat data.json | python3 -m json.tool
# jq (install: brew install jq / apt install jq)
jq '.' data.json
# Node.js one-liner
node -e "process.stdout.write(JSON.stringify(JSON.parse(require('fs').readFileSync('/dev/stdin','utf8')),null,2))" < data.jsonPretty Print vs. Minify: When to Use Each
| Use case | Recommended format |
|---|---|
| Debugging / code review | Pretty print (2 or 4 spaces) |
| Production API responses | Minified |
| Config files committed to git | Pretty print (readable diffs) |
| LLM / AI prompts | Minified (fewer tokens) |
| Logs read by humans | Pretty print |
Catch Parse Errors While Formatting
Our pretty print tool doubles as a validator. If your JSON has a trailing comma or a missing bracket, it highlights the exact line with an error message before formatting. Great for catching problems in API responses.
Pretty Print Your JSON Instantly
Paste minified or messy JSON and get a beautifully formatted result in one click. No sign-up required.