An API response lands in your editor as a single line several thousand characters long. Somewhere inside it is the one value you need, but the line offers no handholds: no beginning to any section, no visible end to any list. It looks like a data problem. It is actually a presentation problem, with a two-part fix.
Part one is mechanical: format the JSON so its structure becomes visible. Part two is a reading technique: take the tree one level at a time instead of trying to absorb it whole. This guide covers both, using the free JSON Formatter and Validator on Ovatly, which runs in your browser and uploads nothing.
Contents
- Quick answer
- Why nested JSON looks worse than it is
- Indentation is the map
- Read level by level: keys first, one branch at a time
- Arrays: the first item teaches the rest
- How to format and read JSON, step by step
- Worked example: extending a small object
- Limitations and honest tradeoffs
- Common mistakes
- FAQs
- Conclusion
- References
Quick answer
Paste the one-line JSON into the JSON Formatter and Validator and format it with 2 or 4 space indentation. Then read it as a tree: note the top-level keys, follow one branch at a time, and use matching brackets to know where each branch ends. When you meet an array of objects, read the first item carefully and treat the rest as the same shape repeated. If the text refuses to format, it is invalid, and the error names the problem to fix first.
Why nested JSON looks worse than it is
JSON has exactly two ways to build structure: objects, which group named values, and arrays, which list values in order. Everything in a response, however large, is those two shapes nested inside each other. The complexity you feel looking at a raw response is not many kinds of structure; it is the same two kinds, repeated at depth, with the depth hidden.
Minification hides it deliberately. Whitespace carries no meaning for a parser, so responses ship with the indentation stripped out to save bytes: right for transfer, wrong for a human. Restoring it is not cosmetic: the indent level is literally a picture of the nesting depth, which is the thing you were missing.
Indentation is the map
Once formatted, every line's position tells you where it sits in the tree. Keys at the left margin are the top level. Each step right is one level deeper. A closing bracket at the same indent as its opening line marks the exact end of that branch, so you can see a section's size before reading a single value in it.
The formatter offers 2 or 4 space indentation. Two spaces keep a deep tree compact; four spaces make levels easier to tell apart when nesting is shallow. Neither changes the data; choose based on the depth in front of you.
Read level by level: keys first, one branch at a time
With the map visible, resist reading top to bottom. Read in passes instead.
First pass: read only the top-level keys and ignore their values. This gives you the response's table of contents in a handful of words. Second pass: pick the one branch that holds what you came for, and read only that branch, again keys first if it is an object. Third pass: within that branch, read the actual values.
Matching brackets are how you keep your bearings. When you open an object or array, find its closing bracket at the same indent before reading inside it. Knowing a branch is twelve lines long, and where it ends, is most of what "not getting lost" means.
Arrays: the first item teaches the rest
Arrays are where readers drown, because a list of two hundred objects looks like two hundred problems. It is one problem stated two hundred times. Items in a JSON array, especially in API responses, are almost always the same shape: the same keys, in the same order, with different values.
So read the first item completely and understand its structure. After that, the remaining items need only a skim: you are checking values, and watching for the occasional item that breaks the pattern with an extra key or a null. Collapsing the array mentally to "one of these, repeated" turns the longest section of a response into the fastest to read.
How to format and read JSON, step by step
- Open the JSON Formatter and Validator and paste the response exactly as it arrived.
- Format it, choosing 2 space indentation for deep responses or 4 space for shallow ones. If it will not format, the tool names the error instead; fix that first.
- Read the top-level keys only, and name what each branch holds before opening any of them.
- Follow the one branch you need, keys first, locating its closing bracket before reading inside.
- Inside arrays, read the first item in full, then skim the rest.
Worked example: extending a small object
Start with a flat object:
{"name":"Ovatly","tools":250,"free":true}
Formatted, it is three readable lines. Now extend it the way real responses grow: a nested object, and an array of related entries.
{
"name": "Ovatly",
"tools": 250,
"free": true,
"category": {
"name": "Data and JSON",
"cluster": "data-and-json-tools"
},
"related": [
{ "title": "JSON Formatter and Validator", "free": true },
{ "title": "JSON to CSV Converter", "free": true }
]
}
Read it with the technique. Top-level keys: name, tools, free, category, related. The category branch is a small object with two keys; its closing brace, level with the word category, shows it ends before related begins. The related branch is an array: the first item has title and free, so the second item needs no structural reading, just its values. The whole structure is now a sentence you can say out loud, which is the test of having read it.
Limitations and honest tradeoffs
Formatting reveals structure; it does not explain meaning. A formatted tree will not tell you what a cryptic field name stands for or which of forty fields the bug involves. It makes the search possible, not finished.
Two practical limits matter. First, formatting requires valid JSON: a trailing comma, single-quoted string or comment makes the text invalid under the strict standard, and the tool will report the error rather than a tree. Second, size and precision: very large pastes, in the tens of megabytes, may take a moment, and because number handling follows JavaScript, integers beyond 2^53 can lose exactness when JSON is parsed and rewritten. Neither affects ordinary responses, but both are worth knowing before you paste a huge export. The tool is fully local, so none of this involves uploading your data.
Common mistakes
- Reading the raw one-line form. You are fighting the shipping format, not the data. Format first, always.
- Reading strictly top to bottom. You end up deep in a branch you do not need, holding five open brackets in memory. Read keys first, then one branch.
- Expanding every array item mentally. Read the first item's structure and skim the rest; the shape repeats.
- Losing track of closing brackets. Find the matching close before reading a branch's contents.
- Assuming a format failure means the tool failed. It means the JSON is invalid. The error names the spot; fix it and the tree appears.
FAQs
Why does API JSON arrive as one long line? Because it is usually minified for transfer: whitespace costs bytes and means nothing to the parser. The one-line form is a shipping format, not a reading format, so the right first move is always to format it with indentation.
Should I use 2-space or 4-space indentation? Either works; the formatter offers both. Two spaces keep deep trees narrower on screen, four spaces make each level easier to distinguish at a glance. Pick the one where you can still see the deepest level without scrolling sideways.
Does formatting change the data? No. Formatting changes only whitespace; the values, keys and structure are the same. One caution: number handling follows JavaScript, so integers beyond 2^53 can lose exactness when JSON is parsed and rewritten. For reading ordinary responses this does not arise.
What if the JSON will not format at all? Then it is not valid JSON, and the tool reports the problem in plain words instead, such as an unexpected character or a missing comma. Fix that spot first; once the text validates, it will format. Our companion guide on validating JSON before sending it to an API covers that workflow.
Is the JSON I paste uploaded to a server? No. The formatter runs locally in your browser and nothing is uploaded, so it is safe to format responses that contain account data or other details you would not paste into a remote service.
Conclusion
Nested JSON stops being intimidating once you separate the two jobs: let the JSON Formatter and Validator restore the indentation, then read in passes, keys first, one branch at a time, arrays by their first item. The companion problem, JSON that will not parse at all, is covered in our guide on how to validate JSON before sending it to an API. More guides in this series live in the Data and JSON Tools guides.
References
- JSON.org, an introduction to JSON's two structures, objects and arrays: https://www.json.org/json-en.html
- MDN Web Docs, on working with JSON and its data types: https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Scripting/JSON