How to pretty print JSON
- Paste JSON or press Open file.
- Pick an Indent: 2 spaces, 4 spaces or Tabs.
- Press Pretty print or Ctrl + Enter.
Example
{"city":"Zürich","station":"Hauptbahnhof","platform":"41/42","departures":[{"line":"S3","to":"Wetzikon","in":4,"price":4.40},{"line":"IR 75","to":"Konstanz","in":11,"price":31.00}],"note":"Gleis 41 → Ausgang Süd"}
With 2 spaces:
{
"city": "Zürich",
"station": "Hauptbahnhof",
"platform": "41/42",
"departures": [
{
"line": "S3",
"to": "Wetzikon",
"in": 4,
"price": 4.40
},
{
"line": "IR 75",
"to": "Konstanz",
"in": 11,
"price": 31.00
}
],
"note": "Gleis 41 → Ausgang Süd"
}
The prices stay 4.40 and 31.00. JSON.stringify(JSON.parse(text), null, 2) prints 4.4 and 31, and Python’s json.dumps prints 4.4 and 31.0, because both convert the numbers; this page only re-indents the text. Duplicate keys survive too: both "status" lines stay, where JSON.parse keeps only the second.
Indentation costs bytes: the example is 217 bytes on one line, 287 with tabs, 325 with 2 spaces and 401 with 4. A tab is one character per level, shown at each editor’s own width. JSON minify puts it back on one line.
Escape non-ASCII
Escape non-ASCII writes every non-ASCII character, in keys and values, as a \u escape:
"city": "Z\u00fcrich",
"note": "Gleis 41 \u2192 Ausgang S\u00fcd"
Emoji and other characters beyond the Basic Multilingual Plane become a pair, like \ud83d\ude86. Both forms parse to the same string. The escaped one survives systems that mangle UTF-8 and matches Python’s default ensure_ascii=True output.
JSON inside a string
Logs often carry JSON as an escaped string, such as "{\"id\":7,\"tags\":[\"a\"]}". To a parser that is one string value, so pretty printing leaves it on one line. Unescape it first in JSON escape with Mode set to Unescape.
Pretty print JSON in code
- JavaScript:
JSON.stringify(data, null, 2), more in pretty print JSON in JavaScript - Python:
json.dumps(data, indent=2, ensure_ascii=False), more in Python pretty print JSON - Terminal:
python -m json.tool data.jsonorjq . data.json, more in pretty print JSON on the command line
If the input does not parse, the Report tab shows where it stops.