JSON Formatter
Format and beautify minified JSON with proper indentation.
Was this tool helpful?
Thanks for the feedback!
The JSON Formatter takes compact or messy JSON, such as an API response on one line, and re-prints it with two-space indentation so the structure is easy to follow. If the input is not valid JSON, you get the parser's error message with the position of the problem instead, so the formatter doubles as a quick syntax check.
Formatting an API response
This single line from an order API:
{"order":{"id":"ORD-1042","total":1499.00,"items":[{"sku":"TSHIRT-M","qty":2}]},"paid":true}
is printed as:
{
"order": {
"id": "ORD-1042",
"total": 1499,
"items": [
{
"sku": "TSHIRT-M",
"qty": 2
}
]
},
"paid": true
}
Look closely at total: 1499.00 became 1499. The formatter parses the JSON into JavaScript values and prints them again, so the data is identical but its written form can change.
Side effects of parsing and re-printing
- Numbers are normalised.
1.50becomes1.5and1e3becomes1000. - Very large integers lose precision. JavaScript numbers are exact only up to 9,007,199,254,740,991. An ID like
12345678901234567890is shown as12345678901234567000. If your API uses 64-bit IDs, don't copy them from the formatted output. - Duplicate keys collapse. If an object contains the same key twice, only the last value remains.
- Numeric-looking keys move first. Keys such as
"2"and"1"are listed before other keys, in ascending order, because that is how JavaScript orders object properties. - Escapes are decoded.
"caf\u00e9"is shown as"café".
Reading the error messages
Errors come from your browser's JSON parser, and Chrome and Edge include a line and column, for example "Expected double-quoted property name in JSON at position 7 (line 1 column 8)". The usual causes:
- Trailing comma after the last item, as in
{"a":1,}. JavaScript allows it; JSON doesn't. - Single quotes around keys or strings. JSON requires double quotes.
- Unquoted keys like
{name: "x"}, which is a JavaScript object literal, not JSON. - Comments.
//and/* */aren't part of JSON, even though some config files use them. - Truncated input, shown as "Unexpected end of JSON input", often because a log line or copied response was cut off.
When an integration fails, format the raw response first. It is often an HTML error page or an empty body rather than the JSON you expected, and the error message makes that obvious in seconds.
Related JSON tools
Parsing runs in your browser, which makes it reasonable for responses containing internal data, though redacting tokens before sharing formatted output is still a good habit. To compress JSON again, use the JSON Minifier; to generate TypeScript interfaces from the same sample, try JSON to TypeScript.