You asked an API for one record and it answered with a single line that runs off the edge of the screen. Somewhere inside that line are the fields you need, nested three levels deep, but reading it means counting braces with your eyes. Copying it into a ticket or a document helps nobody, because the next person faces the same wall of text.

The fix takes seconds: pretty print the response. Paste the one-line JSON into the free JSON Formatter and Validator on Ovatly, pick an indent, and the same data comes back as a structured document you can actually read. This guide covers the steps, and two honest warnings about very large responses and very large numbers.

Contents

  • Quick answer
  • Why API responses arrive on one line
  • What pretty printing changes, and what it does not
  • How to pretty print an API response, step by step
  • Worked example: one line in, structure out
  • Two honest warnings: size and precision
  • Limitations and honest tradeoffs
  • Common mistakes
  • FAQs
  • Conclusion
  • References

Quick answer

Copy the raw response, open the JSON Formatter and Validator, paste the text in, choose a 2 or 4 space indent, and format. The output is the same data with one field per line and nesting you can follow visually. Two warnings: a very large response, tens of megabytes, may take a moment to process, and reformatting parses the numbers, so integers beyond 2^53 can lose exactness. If you are checking a response that carries long numeric IDs and the exact digits matter, use Validate only instead, which checks the JSON without changing a single character.

Why API responses arrive on one line

Servers send JSON in its cheapest form: no indentation, no line breaks, nothing spent on whitespace that a program does not need. That is the right choice for machine-to-machine traffic, where the reader is code and smaller responses travel faster. The problem starts when a human becomes the reader: when you are debugging an integration, checking what an endpoint actually returned, or pasting evidence into a bug report.

Pretty printing is the translation step between those two audiences. It takes the compact form and lays it out for eyes, without asking the API to change anything.

What pretty printing changes, and what it does not

Pretty printing changes whitespace only. Keys, values, ordering and nesting are exactly what the API sent; the formatter parses the text to understand the structure, then writes it back out with line breaks and indentation that mirror the nesting. A field three levels deep sits three indents in, so the shape of the data is visible before you read a single value.

Because the output is rebuilt from parsed data, two side effects deserve honesty. Formatting a valid response also confirms it is valid: broken JSON cannot be pretty printed, and the tool will tell you why instead. And numbers pass through the parser, which leads directly to the precision warning below.

How to pretty print an API response, step by step

  1. Copy the complete response body, from the first opening brace or bracket to the last closing one. A partial copy will fail validation, because the structure is incomplete.
  2. Open the JSON Formatter and Validator and paste the response into the input.
  3. Choose your indent: 2 spaces for deeply nested responses, 4 spaces when the document is shallow and you want maximum separation between levels.
  4. Format, then read or copy the result. If the response is broken, the tool names the problem in plain words, such as an unexpected character or a missing comma, instead of printing a tidier version of the error.

Worked example: one line in, structure out

This is the shape of what an API hands you, a small object flattened onto one line:

{"name":"Ovatly","tools":250,"free":true}

After formatting with indentation, the same object reads like this:

{
  "name": "Ovatly",
  "tools": 250,
  "free": true
}

Nothing was added and nothing was removed. The three fields were always there; the second version simply lets you see them. Scale that difference up to a real response with hundreds of fields and nested objects, and it is the difference between searching a haystack and reading a list.

Two honest warnings: size and precision

Size. Very large pastes may take a moment. A response of tens of megabytes is a lot of text for any in-browser tool to parse and rebuild, so expect a pause rather than an instant result. If a response is that big, consider whether you need all of it: many APIs let you request fewer fields or a single record, and a smaller paste formats instantly.

Precision. Number handling follows JavaScript, and integers beyond 2^53 lose exactness when the text is reformatted. In practice this bites one kind of value: long numeric IDs. An ID like 9007199254740993 can come back from a reformat with its last digit changed, because the parser cannot hold it exactly. Strings are never touched, so an ID sent as a quoted string is safe. If the exact digits of a large number matter to you, do not reformat that response. Use Validate only, which checks the JSON and leaves every character exactly as the API sent it.

Limitations and honest tradeoffs

The formatter checks your paste against the strict JSON standard. Trailing commas, single-quoted strings, unquoted keys and comments are all invalid, and there is no JSONC support, so a response decorated with comments will be refused even if the tool that produced it accepted them. The error message names the problem in plain words, which makes the fault findable, but the fix is still yours to make.

Formatting also cannot judge meaning. It will happily pretty print a response whose values are wrong, out of date or missing a field the API should have sent. Structure is what it verifies, not truth.

Common mistakes

  • Reformatting a response whose long IDs you need exactly. Parse-based formatting can change the final digits of integers beyond 2^53. Validate only, or read the digits from the raw response.
  • Pasting a partial response. Half a JSON document is invalid JSON. Copy the whole body, first brace to last.
  • Assuming a refused paste means the API is broken. The standard is strict: a trailing comma or a comment is enough to fail, and the error message will point at it.
  • Switching indent styles mid-project. Formatted output that lands in docs and tickets should look the same every time. Pick 2 or 4 spaces once and keep it.

FAQs

Does pretty printing change the data in the JSON? The values stay the same, but the text is rebuilt from the parsed data, so whitespace changes completely and very large integers can lose exactness. Integers beyond 2^53 are not represented exactly once the JSON is parsed, which is why a long ID can come back with different final digits.

Should I choose a 2 space or 4 space indent? Both are fine. Two spaces keeps deeply nested responses compact on screen, four spaces makes each level easier to scan in a shallow document. Pick one and stay consistent, especially if the formatted output goes into documentation or a bug report that other people will read.

Is my API response uploaded to a server? No. The formatter runs in your browser and the response never leaves your device. That matters for API data, which often contains account details, tokens or customer records that should not be pasted into a remote service.

Why did the formatter refuse my API response? The JSON standard it checks against is strict. Trailing commas, single-quoted strings, unquoted keys and comments are all invalid, and the tool reports the problem in plain words, naming things like an unexpected character or a missing comma, so you can find the fault.

What if I only need to check the response, not reformat it? Use Validate only. It checks the JSON against the standard and reports any error without changing the text at all, which also means number precision is never touched.

Conclusion

A one-line API response is written for machines; pretty printing rewrites it for you. Paste it into the JSON Formatter and Validator, choose an indent, and read the structure instead of hunting through it, keeping Validate only in mind for the responses whose exact digits matter. If your paste gets refused over quote marks, our companion guide on single quotes vs double quotes in JSON explains what parsers accept and why. For more guides in this series, see our Data and JSON Tools guides.

References