- 1Paste or load JSON
- 2Parse the input
- 3Read the indented result
What JSON formatting changes
JSON syntax does not require spaces or line breaks between tokens. Minifiers remove optional whitespace to reduce payload size. A formatter parses the JSON value and writes it back with consistent indentation, line breaks, and spacing. It should preserve values and array order; object key order is generally not meaningful to JSON consumers.
Minified
{"order":{"id":"ord_1042","status":"packed","items":[{"sku":"MUG-02","quantity":2}],"shipping":{"country":"CA","priority":false}}}Formatted
{
"order": {
"id": "ord_1042",
"status": "packed",
"items": [
{ "sku": "MUG-02", "quantity": 2 }
],
"shipping": {
"country": "CA",
"priority": false
}
}
}Here the indentation exposes that items is an array of objects and shipping is a separate nested object. The data itself has not gained fields or changed types.
How indentation reveals nesting
Each additional indentation level means the parser is inside another object or array. Matching closing braces line up with the opening structure. A compact object on one line can still be valid; the layout is for people and tools that compare text.
One level at a time
Format JSON online
Open the JSON Viewer, paste the complete payload, and use its format action or switch to the tree view to inspect nested values. The tool has formatting, validation, and tree inspection capabilities. If you only need indentation, copy the formatted output back into your editor.
Formatting is not the same as validation
To pretty print JSON, a formatter must parse it first. That parse step can tell you whether the text follows JSON syntax. It does not prove the payload has the fields your application expects. A syntactically valid response with "quantity": "2" may still violate an API contract expecting a number.
What formatting preserves—and what it may normalize
Indentation is whitespace outside strings, so adding it does not change string values. A formatter should also leave array order intact. However, formatting is a parse-and-serialize step, not a byte-for-byte edit: a serializer may reorder object keys or normalize a number such as 1.00 to 1. Those representations parse to the same JSON number, but the original text is different. If a signature, checksum, or exact text comparison depends on the original bytes, keep that source and do not substitute pretty-printed output.
Indent size is a readability preference, not part of the JSON format. Two spaces are compact enough for deeply nested responses; four spaces can be easier to scan in a narrow code review. Pick one convention for the repository and use the same setting before comparing files. Reformatting both sides first removes whitespace-only noise from a textual diff.
Common formatting problems
If nothing happens or the tool reports an error, check that you copied the entire response, including its first and last braces. Trailing commas, comments, single-quoted strings, and literal line breaks inside strings are not valid JSON. A formatter cannot safely guess what malformed text was intended to mean.
Pretty printing is especially useful when comparing API responses across environments, reviewing a webhook payload, or finding whether a field is nested under data or at the root. For giant files, formatting everything can make the output much larger; search or inspect selected subtrees instead.
{"ok":true,"count":3,"tags":["new","ready"]}