Developer Tools

How to Read JSON A Beginner’s Guide to API Responses

Almost every app and website exchanges data as JSON. Once you can read its structure, error messages and API responses stop looking like noise.

Quick answer: paste the response into the JSON Formatter so it is indented. Curly braces { } hold named fields, square brackets [ ] hold lists, and you reach nested data by following the names, for example data.items[0].name. Check the HTTP status code first: 200 means success, 4xx means a problem with your request.

In this article
  1. JSON in two minutes
  2. Why raw API responses are hard to read
  3. How to format JSON
  4. Reading a response step by step
  5. Common things you will spot
  6. Sorting keys to compare responses
  7. JSON is not always friendly in spreadsheets
  8. Keep secrets private

JSON in two minutes

JSON (JavaScript Object Notation) is a text format for structured data. It has only a few building blocks:

PartLooks likeMeaning
Object{ "name": "Ali", "age": 30 }A set of named values
Array[ "red", "green" ]An ordered list
String"hello"Text, always in double quotes
Number42, 3.14No quotes
Booleantrue, falseYes / no
NullnullNothing / unknown

Objects and arrays can be nested inside each other as deeply as needed, an order contains a customer object and an array of items, each item an object with a name and price.

JSON FormatterFormat and beautify JSON with 2-space, 4-space or tab indentation. Optional key sorting and clear errors with line and column numbers. Runs locally.
Open the free tool

Why raw API responses are hard to read

To save space, APIs usually send JSON on one long line with no spaces. A response of a few kilobytes becomes an unreadable wall of brackets. Formatting adds line breaks and indentation so each level of nesting is visible at a glance.

How to format JSON

  1. Paste the JSON into the JSON Formatter.
  2. Choose 2 spaces, 4 spaces or tabs.
  3. Optionally sort keys A–Z, helpful when comparing two responses.
  4. Copy the formatted result. If the JSON is broken, you see the line and column of the problem.

Reading a response step by step

Take a typical weather API answer. After formatting you will see something like a top-level object with keys such as "location", "current" and "forecast". Read top-down: first the keys at the outer level, then open each one. A path such as forecast.days[0].maxTemp means “inside forecast, in the days array, the first item’s maxTemp”. Arrays start counting at 0.

Common things you will spot

  • Error objects: many APIs return {"error": {"code": 401, "message": "Invalid API key"}}, the message usually tells you exactly what is wrong.
  • Timestamps: numbers like 1767225600 are Unix time. Convert them with the Timestamp Converter.
  • Encoded data: long strings of letters ending in “=” are often Base64. Decode with the Base64 Decoder.
  • Pagination: keys like next, page or cursor mean there is more data to fetch.

Sorting keys to compare responses

Two responses can contain the same data in a different key order, which makes them look different line by line. Sort keys in both, then paste them into Text Compare, now only real differences are highlighted.

JSON is not always friendly in spreadsheets

If you need the data in Excel or Google Sheets, convert an array of objects to CSV with the CSV ⇄ JSON Converter. Nested objects become dotted column names like customer.city.

Keep secrets private

API responses often contain tokens, personal data and internal IDs. Pasting them into random online formatters can leak them. ConvertNest formats JSON entirely in your browser, nothing is sent to a server.

Frequently asked questions

What is JSON?

A text format that stores data as names and values, used by most web APIs.

How do I make JSON easier to read?

Paste it into a JSON formatter, which adds indentation and line breaks.

What do curly and square brackets mean?

Curly brackets hold objects with named fields. Square brackets hold lists of items.

Why is my JSON invalid?

Common reasons are missing commas, trailing commas, single quotes or unquoted names.

Is it safe to paste API responses into a formatter?

Use a tool that runs in your browser and remove tokens or personal data first.

What is the difference between an object and an array in JSON

An object is a set of named fields inside curly braces. An array is an ordered list inside square brackets, and items are reached by number starting at 0.

Why does my API return an error message in JSON

Many APIs send errors as JSON with a message field. Read the status code and that message together to find the cause.

JSON FormatterFormat and beautify JSON with 2-space, 4-space or tab indentation. Optional key sorting and clear errors with line and column numbers. Runs locally.
Open the free tool
Keep reading

Related articles

All articles
Dev

The Most Common JSON Errors, and How to Fix Each One

“Unexpected token” tells you something is wrong, not what. These are the mistakes behind almost every JSON error, with quick fixes.

3 min read
Dev

Should You Minify JSON? Size, Speed and How Gzip Changes the Picture

Minifying JSON removes spaces and line breaks. It sounds like an obvious win, but how much does it really save, and when should you not bother?

3 min read
Dev

How to Decode Base64 into Text, an Image or a File

A long string of random-looking letters in a log, an email or an API response is often Base64. Here is how to see what is really inside.

3 min read