Best practices 9 min read 1,870 words By LaiUse Editorial Team Reviewed 28 October 2026

How to Read a JSON API Response: A Beginner's Walkthrough

How to Read a JSON API Response: A JSON API response is not a flat list of fields.

Why this matters

A JSON API response is not a flat list of fields. It is a hierarchy of values: an object contains named properties, an array contains ordered items, and each item can itself be an object, array, string, number, boolean, or null. The field you need may be several levels down, and reading the response becomes much easier once you can distinguish the document’s top-level shape from the structure of the values inside it.

Two different tools in this guide help with different parts of that task. json-formatter is appropriate when you need to format, minify, or validate an entire JSON document. json-path-query is appropriate when you know the structure of the document and want to select a particular field or collection of fields. A third tool, base64, is useful only when the value you have extracted is itself Base64-encoded; it is not a JSON viewer or query tool.

It helps to think of formatted output and a tree view as two views of the same shape. Formatted JSON exposes that shape through indentation and line breaks. A tree view would expose it as expandable branches, although neither tool documents an interactive tree-view mode, so this guide does not claim that one of these tools provides such a control. The structural outline can still be read directly from the formatted text: a root object, a data object, a users array, and object properties within each array item.

The process

  1. Identify the kind of payload you received. Begin with the raw response body. A common successful response starts with a top-level object, such as { "status": "ok", "data": ... }. Some endpoints instead return a top-level array, such as [ { "id": 1 }, { "id": 2 } ]. This first distinction determines how you write any path that reaches a nested field.

  2. Open json-formatter when you need to read the whole response. Paste the JSON or upload a file with a .json extension. The tool supports the format, minify, and validate modes. The format mode is the useful choice for inspection because its indented output makes object members and array items easier to follow. The tool processes its input locally according to its capability data, and it also exposes copy and file-download support.

  3. Read from the outside inward. In the formatted output, first locate the root value. If it is an object, look for its named properties. If a property contains an array, remember that the array’s index is part of the path. If an array contains objects, each object’s properties are one level deeper. This is the same relationship that a tree visualization would show: the root branches into children, and each child may branch again.

  4. Use validate when the response is not being accepted as JSON. Run the validate mode to distinguish malformed JSON from a valid document whose contents differ from what you expected. Validation checks the document’s JSON syntax. It does not confirm that the fields match an API schema, and it does not tell you whether an HTTP request succeeded.

  5. Open json-path-query when you know which value you want to extract. Paste the JSON into the area labeled Paste your JSON, or provide a .json file. Unlike json-formatter, this tool supports drag-and-drop. Its processing is marked as local, and it is built around the jsonpath-plus library. Because the query is not marked as automatically running, enter the expression deliberately and then run it.

  6. Enter a path that matches the document’s actual shape. For an object property, use a dotted path such as $.data.users[0].email. The dollar sign refers to the document root, data and users are named properties, 0 selects the first array item, and email selects a property inside that item. Use $[*] or $.data.users[*] when every matching item should be selected. The tool reports an empty expression with Enter a JSONPath expression and rejects malformed expressions with an invalid-expression message.

  7. Check the result against the formatted document. A query returning no matches often means the path is wrong, not that the field is absent from the response. Compare the query’s levels with the hierarchy you saw in the formatted output. Pay particular attention to whether a level is an object property or an array index, and whether an array sits between two named properties.

  8. Copy or download only the result you need. json-path-query supports copying its result but does not offer file download. json-formatter supports both copying and downloading. If the extracted string is encoded data rather than ordinary text, use base64 in decode mode. Its output is labeled Result. Do not send arbitrary JSON to that tool merely to make it readable.

Worked example

Suppose an API returns a successful user listing. The raw body is a top-level object containing status information, a nested data object, and pagination metadata. A realistic abbreviated response is: { "status": "ok", "data": { "users": [ { "id": 1042, "name": "Avery Chen", "email": "avery@example.test", "roles": ["editor", "reviewer"] }, { "id": 1043, "name": "Jordan Patel", "email": "jordan@example.test", "roles": ["viewer"] } ] }, "pagination": { "next_cursor": "eyJpZCI6MTA0M30", "has_more": true } }. After formatting it with json-formatter, the hierarchy is visible: data is an object; users is an array; each array item is an object; and roles is an array of strings. The pagination object is a sibling of data, not a child of it.

If the task is to obtain the first user’s email, the exact query is $.data.users[0].email. To collect every user’s email, use $.data.users[*].email. To retrieve the first user’s roles, use $.data.users[0].roles; selecting that path returns the array, while adding [*] selects its individual values. The next_cursor value resembles Base64, but its name and the surrounding API data do not prove that it is Base64. If the API contract confirms that it is encoded, base64 in decode mode can decode it.

Now consider a different endpoint that returns the users array directly: [ { "id": 1042, "email": "avery@example.test" }, { "id": 1043, "email": "jordan@example.test" } ]. The root is an array, so $.data.users[0].email is wrong. The first email is at $[0].email, and all emails are at $[*].email. This is the central difference caused by assuming every API response has an object at its root.

Common mistakes

Limitations of this approach

Frequently asked questions

How do I know whether the response has a top-level object or array? Look at the first meaningful character in the raw body. A { begins an object, while [ begins an array. Formatted output makes this immediately visible, but the original first character remains the decisive clue.

Why does my JSONPath expression return no match? Compare every level of the expression with the formatted document. Check the root type, property names, array positions, and any nested objects or arrays between the root and the target field. Also confirm that an expression was actually supplied, because an empty expression produces Enter a JSONPath expression.

What is the difference between $.data.users[0].email and $.data.users[*].email? The first selects one email from the first user object. The second selects an email from every item in the users array. The square-bracket wildcard changes the number of selected values, not the location of the users array.

Can json-formatter tell me whether a field is required? No. Its validate mode checks whether the input is valid JSON. It does not compare the document against an API schema or declare one field required and another optional.

Should I use base64 to inspect a JSON response? No, not for normal JSON. Use json-formatter to format or validate the document and json-path-query to select the relevant field. Use base64 only after identifying a particular value that is known to be Base64-encoded.

Can I upload the same response to both JSON tools? Yes, subject to their documented differences. Both accept .json files and provide local-processing support. json-path-query additionally supports drag-and-drop, while json-formatter provides file download as well as copying.

Does an empty array mean that a JSONPath expression is broken? Not necessarily. The array may genuinely be empty. To distinguish the cases, use the format mode and inspect the collection before drawing a conclusion from the query result.

The tools in this guide: json formatter · json path query · base64 — each runs in your browser, so your data stays on your device.

Browse every guide · Read the blog · About LaiUse