Guide · Updated 2026-07-29

JSON and APIs

JSON is the de facto standard format for web API request and response bodies. Here's how the two fit together, and where the "JSON API" naming gets confusing.

Why APIs use JSON

When your browser or app calls a web API, the server needs to send structured data back in a format both sides understand. JSON won out over alternatives like XML for most modern APIs because it's compact, maps directly onto data structures every language already has (objects, arrays, strings, numbers), and requires far less code to parse and generate.

Request and response bodies

A typical API exchange sends a JSON object in the request body (for POST/PUT requests) and receives a JSON object or array back in the response body. Both are typically marked with an application/json content-type header, which tells the receiving system how to interpret the raw bytes.

REST APIs vs. the JSON:API specification

This is where naming gets confusing: "a JSON API" (lowercase, generic) just means an API that uses JSON — the vast majority of REST APIs. JSON:API (with the colon) is a specific, formal specification that defines exact conventions for structuring resources, relationships, and errors within JSON responses. Most APIs you'll encounter use plain, ad-hoc JSON structures rather than following the JSON:API spec.

Common gotchas

A frequent one: some APIs stringify their JSON payload twice, so the response body is itself a JSON string containing another JSON string — our JSON Parser handles this automatically. Another: dates in JSON are just strings (JSON has no native date type), so both sides need to agree on a format like ISO 8601.

Frequently asked questions

Why do most web APIs use JSON?

JSON is compact, human-readable, and natively supported by virtually every programming language, making it faster to parse and easier to debug than alternatives like XML for typical API payloads.

What is the JSON:API specification?

JSON:API is a specific convention for structuring JSON responses in REST APIs — defining how resources, relationships, and errors are formatted. It's a specification built on top of JSON, not JSON itself; most APIs use plain JSON without following it.

What content-type header should a JSON API use?

application/json is the standard content-type for JSON request and response bodies, telling the receiving system how to parse the payload.