How to view JSON: choosing a view that fits the data
Learn how to read JSON responses by checking their shape first, then choosing a text, table, card, or tree view to trace nested values.
Reading JSON is mostly a matter of orientation. Before you worry about a particular value, you want to know what kind of document you are holding, how deep it goes, and whether it is made of one record or many. Once you know that, picking a way to display it is straightforward. This guide walks through that process with small, real-looking examples, and explains when plain formatted text is enough and when a table, cards, or a tree will serve you better.
Start with the shape of the data
Look at the first non-whitespace character. An opening brace means the top level is an object, a set of named fields. An opening bracket means it is an array, an ordered list of items. A JSON text can also be a bare string, number, true, false, or null, since RFC 8259 allows any value at the top level, though that is rare in practice.
The distinction tells you where to look first. An object usually has a few keys that act as a table of contents: a status, some metadata, and one or two large members holding the real content. An array tends to be a list of similar things you may want to compare. Reading the top-level keys and noting which of them is largest takes ten seconds and saves a lot of scrolling.
{
"status": "ok",
"requestId": "req_8f2c1a",
"page": 1,
"results": [
{ "id": 1, "title": "Quarterly report", "tags": ["finance", "draft"] },
{ "id": 2, "title": "Onboarding guide", "tags": [] }
]
}Make the text readable first
If the document arrives on one line, format it before doing anything else. Pretty-printing adds indentation and line breaks and leaves the data untouched. It is also a cheap validity check: if the formatter refuses, the text is not valid JSON, and you should fix that before trying to interpret any values.
Common causes of invalid input are worth knowing by heart. A trailing comma after the last element, single quotes instead of double quotes, a comment someone left in a config file, or an unquoted key copied from a JavaScript object. A response that was truncated by a timeout, or a body that has been JSON-encoded twice so it is one long string full of backslashes, will also fail. The second case is easy to spot because the whole document starts and ends with a quote mark.
"{\"status\":\"ok\",\"count\":2}"When a table is the right view
Use a table when you have an array of objects that share most of their keys. Each object becomes a row and each key becomes a column, so you can scan down a column and compare values quickly. It is the best view for spotting a missing field, a value of the wrong type, or a row that does not look like its neighbours.
In the example above, the results array is a good candidate. Tables are less helpful for a single object, and nested arrays inside cells, like the tags list, are only partly flattened, so you may still want to open the nested value separately.
When cards or a tree work better
Cards group each object's fields together, which makes them good for reading records one at a time or for a short list where every field matters and you want labels beside values. They are the most comfortable view for something like a user profile or a product entry.
A tree is the right tool for depth. Configuration files, GraphQL responses, and cloud resource descriptions often nest six or seven levels. A tree view lets you expand just the branch you need and keep the others folded, and it usually shows you the path to a value as you go. That path is what you will end up writing in code, so it is useful to read it directly.
View My JSON provides all three, plus Format and Validate, in its free tier, so you can paste a document once and switch between them without reformatting anything.
Tracing a nested value to its path
Suppose you need the city of the second address of the first customer in the document below. In text you count brackets. In a tree you expand customers, then item zero, then addresses, then item one, and read the city. The path is customers[0].addresses[1].city, remembering that array positions start at zero.
Writing the path out before you write code is a good habit. Many bugs in JSON handling come from assuming a field is always present or that an array always has an element at a given index. Look at several records, not only the first, before deciding which fields you can rely on.
{
"customers": [
{
"id": "c-17",
"name": "Lena Fischer",
"addresses": [
{ "type": "billing", "city": "Hamburg" },
{ "type": "shipping", "city": "Lübeck" }
]
}
]
}Watching for the usual surprises
Some findings recur. Numbers that should be numbers arrive as strings. A key that is missing from some records is present with a null in others, and your code treats them differently. Large integers lose precision when a JavaScript parser reads them, because JSON numbers are decimal text but many parsers store them as double-precision floats; RFC 8259 notes that interoperability is only reliable within that range. Identifiers that exceed it are safer sent as strings.
Character encoding is another quiet trap. JSON exchanged between systems must be UTF-8, and non-ASCII text such as the ü in Lübeck above should appear either directly or as an escape sequence like \u00fc. If you see garbled characters, the problem is usually a mismatch between the encoding the file was saved in and the one the reader assumed, not the JSON itself.
A worked example of choosing a view
Take the search response from the first example. The envelope has four keys, and only results matters. The results array holds two records with a title and a tags list. That is a job for a table: you would compare titles, and notice that the second record has an empty tags array.
Now suppose the task changes and you are asked why the tags field is sometimes a string and sometimes an array. A table helps you find the odd row, but to understand how the producing system builds the value, you will want the original structure around it, and a tree shows that. The lesson is that the view is a tool for a question. Decide what you are trying to learn, then choose the display that makes that answer visible.
Keep a copy of the original
When you are investigating, avoid editing the only copy of the response. Keep the original in a file, make changes in a working copy, and compare if you need to. Formatting, sorting keys, or deleting a field to see what happens is all fine, as long as you can get back to what the server actually sent.