Home → JSON Pretty Print Online
Pretty printing JSON converts compact one-line JSON into readable indented format.
Pretty printing JSON converts compact one-line JSON into readable indented format. This tool runs entirely in your browser — no data is ever sent to a server. Free to use, no account required.
JSON pretty printing transforms compact or raw JSON into a structured, indented layout that is easy to read and understand.
The formatter adds consistent indentation — typically 2 or 4 spaces per nesting level — so that each key-value pair appears on its own line. You can choose your preferred indentation style.
Deeply nested objects and arrays are each indented one additional level, making the hierarchy immediately visible at a glance. Closing brackets align with their opening counterparts.
Pretty printing is useful whenever you need to read, share, or debug JSON that arrives in a compact or unformatted form.
API responses often arrive as single-line minified JSON. Pretty printing makes them readable in seconds, helping you spot missing fields or unexpected values quickly.
When including JSON examples in documentation or tickets, formatted JSON is far easier for reviewers to understand than a single dense string.
The following examples show the same JSON data in minified (compact) form and then pretty-printed with 2-space, 4-space, and tab indentation. The data is identical in all four cases — only the whitespace changes.
{"user":{"name":"Alice","age":30,"roles":["admin","editor"],"address":{"city":"London","zip":"EC1A 1BB"}}}
{
"user": {
"name": "Alice",
"age": 30,
"roles": ["admin", "editor"],
"address": {
"city": "London",
"zip": "EC1A 1BB"
}
}
}
{
"user": {
"name": "Alice",
"age": 30,
"roles": ["admin", "editor"],
"address": {
"city": "London",
"zip": "EC1A 1BB"
}
}
}
Each indentation style has trade-offs. Choose based on your team conventions, target language, and output destination.
| Style | Bytes per level | Best for | Used by default in |
|---|---|---|---|
| 2 spaces | 2 | Web APIs, JavaScript projects, most linters | JSON.stringify(x, null, 2), Prettier, ESLint |
| 4 spaces | 4 | Python, Java, C# codebases | json.dumps(x, indent=4), Jackson |
| Tabs | 1 char | Editors using tab indentation | Go gofmt, some XML editors |
| Compact (minified) | 0 | Production API responses, storage, transmission | JSON.stringify(x) with no space arg |
You do not need an online tool if you are already writing code. Here is the one-liner for pretty printing JSON in the most popular languages.
// Pretty print with 2-space indentation
const formatted = JSON.stringify(myObject, null, 2);
console.log(formatted);
// From command line (Node.js)
// node -e "console.log(JSON.stringify(require('./data.json'), null, 2))"
import json
# Pretty print an object
print(json.dumps(my_dict, indent=2))
# From command line — pipe any JSON through Python:
# echo '{"name":"Alice"}' | python3 -m json.tool
<?php
$formatted = json_encode($data, JSON_PRETTY_PRINT);
echo $formatted;
# Using jq (most powerful)
cat data.json | jq .
# Using Python (no extra tools needed)
cat data.json | python3 -m json.tool
# Using node
cat data.json | node -e "const d=require('fs').readFileSync('/dev/stdin','utf8');console.log(JSON.stringify(JSON.parse(d),null,2))"
ObjectMapper mapper = new ObjectMapper();
mapper.enable(SerializationFeature.INDENT_OUTPUT);
String formatted = mapper.writeValueAsString(myObject);
Readable JSON is not just cosmetic — it directly impacts developer productivity and code quality. Minified JSON that arrives in a browser's Network tab or a server log as a single line of 10,000 characters can take minutes to parse visually. A pretty-printed version reveals structure, nesting depth, missing fields, and data type mismatches at a glance. Code reviews with formatted JSON examples catch errors that reviewers would miss in dense minified output. Documentation with pretty-printed examples is significantly easier to understand and follow.
For production systems, always keep the minified version for transmission and storage — it reduces bandwidth and parse time. Use pretty printing exclusively during development, logging, debugging, and documentation. Most API testing tools (Postman, Insomnia, browser devtools) automatically pretty print responses for you, but having a dedicated online tool is invaluable when you need to quickly check a JSON string copied from a log file or database.
Explore more tools: All JSON Tools | Validator | Pretty Print | JSON Diff