Ever opened an API response in dev tools and found one giant line of JSON with no line breaks at all? This guide covers why APIs return data that way, exactly what a formatter does to it, and the JSON syntax mistakes people run into most often.
Why APIs return minified JSON
It's inconvenient to read, but a reasonable choice from the server's side. Indentation, line breaks, and whitespace are pure decoration — they carry no data — yet they still add to the bytes sent over the wire. For large responses or high-traffic APIs, stripping that whitespace meaningfully shrinks payload size, which helps both bandwidth and response time. So most APIs default to minified JSON rather than a human-friendly layout, leaving readability to be handled on the client or in dev tools when it's actually needed.
What a formatter does — same data, different shape
A JSON formatter (prettifier) never changes the underlying data. Keys, values, arrays, and object structure stay exactly the same — it only adds indentation matching the nesting depth and puts each entry on its own line. For example, the minified JSON {"user":{"id":1,"tags":["a","b"]}} becomes:
{
"user": {
"id": 1,
"tags": ["a", "b"]
}
}
Internally this happens in two steps: parse the JSON string into a data structure (an object tree), then serialize that structure back out following indentation rules. Because the parsing step rejects invalid syntax, a formatter doubles as a validator, not just a readability tool.
Common JSON syntax pitfalls
JSON looks similar to a JavaScript object literal, but it follows a much stricter standard (RFC 8259). Frequent mistakes include:
- No trailing commas —
{"a":1,"b":2,}fails to parse because of the comma after the last item. - Keys must be double-quoted —
{a:1}and{'a':1}are both invalid; only{"a":1}is valid. - No comments — neither
// ...nor/* ... */exist in standard JSON. - No single quotes — string values must use double quotes; single quotes are a syntax error.
- No undefined, functions, or NaN — JSON is a pure data format and can't represent JavaScript-specific values.
Why formatting helps you debug
Spotting a syntax error in a single unbroken line of JSON is tedious — you end up manually counting brackets to find where something doesn't match. Once indentation is applied, the nested structure becomes visually obvious, making it far easier to spot an unmatched bracket or an array that's nested one level deeper than expected. Formatted JSON is also just a faster way to get your bearings the first time you look at a complex, deeply nested API response.
Paste in minified JSON and you'll get an instantly indented, readable version — with any syntax errors flagged right away — using our free tool.
📘 Try it yourself with the tool
Using a JSON Formatter to Read API Responses — Turn minified JSON into something readable