Paste messy JSON, get clean and readable output instantly
Drop any compressed or hard-to-read JSON into the box above and hit Format. The tool indents every key-value pair with 2 spaces, adds line breaks, and outputs something your eyes can actually follow - all in your browser, with nothing sent to any server.
How to pretty print JSON online
- Paste your raw JSON into the input box.
- Choose your indent size (2 spaces is the default; 4 is also common).
- Click Format (or Pretty Print).
- Copy the output or download it as a
.jsonfile.
If your JSON has a syntax error, the tool highlights the problem line and shows the exact error message so you can fix it fast.
JSON pretty print example
Here is a single-line minified JSON string:
{"user":{"id":42,"name":"Alice","roles":["admin","editor"],"active":true}}
After pretty printing with 2-space indentation, the same data looks like this:
{
"user": {
"id": 42,
"name": "Alice",
"roles": [
"admin",
"editor"
],
"active": true
}
}
Every nested object or array gets its own level of indentation. The data itself is unchanged - only the whitespace and line breaks are added.
How to pretty print JSON in code
If you need to do this inside a script rather than a browser, here are the standard one-liners:
Python
import json
raw = '{"user":{"id":42,"name":"Alice"}}'
data = json.loads(raw)
print(json.dumps(data, indent=2))
json.dumps() with indent=2 is the Python standard-library way to get pretty-printed output. Change 2 to 4 for wider indentation.
JavaScript / Node.js
const raw = '{"user":{"id":42,"name":"Alice"}}'
const data = JSON.parse(raw)
console.log(JSON.stringify(data, null, 2))
The third argument to JSON.stringify() sets the indent level. null in the second position means "include all keys". This works in any modern browser console as well as Node.js.
Command line (jq)
echo '{"user":{"id":42}}' | jq .
jq pretty prints JSON by default when you pass . as the filter. It also colorizes the output in terminals that support it.
How it works
The formatter parses your input into a data tree (just like a browser does with JSON), then serializes it back out with configurable whitespace added at each nesting level. This process follows the JSON specification, so key order is preserved exactly as you wrote it.
Because everything runs in your browser using JavaScript, your data never leaves your device. No upload, no server, no logs.
When to use pretty print - and when not to
| Situation | Pretty print? | Why |
|---|---|---|
| Reading an API response | ✅ Yes | Easier to spot the keys you need |
| Debugging a config file | ✅ Yes | Errors are obvious at a glance |
| Checking a data type or value | ✅ Yes | No squinting at a single line |
| Sending JSON in a network request | ❌ No | Extra whitespace adds unnecessary bytes |
| Storing JSON in a database column | ❌ No | Compact form saves space |
| JSON inside another format (HTML, CSV) | ❌ No | Line breaks break the surrounding format |
When you need the opposite - stripping all whitespace to shrink a payload - try the JSON Minifier. For a full-featured view with collapsible tree nodes, see the JSON Viewer.
Related tools you might need
- JSON Beautifier - Format, Validate & Minify JSON Online - the full-featured formatter with sort-keys and extra options
- JSON Validator - Check & Fix JSON Errors Online - focuses on finding and explaining syntax mistakes
- JSON to YAML Converter - convert indented JSON to YAML format
- YAML to JSON Converter - go the other way and turn YAML back into JSON
Bottom line: pretty printing turns unreadable JSON into something you can scan and understand in seconds. Paste your JSON above and see it formatted right now.