What JSON is
JSON (JavaScript Object Notation) is a text format for structured data: objects, arrays, strings,
numbers, booleans, and null. It says nothing about APIs. You can use it for configuration
files, logs, message queues, or any other data interchange.
{
"id": 1,
"title": "JSON:API paints my bikeshed!",
"author": {
"id": 9,
"name": "Dan Gebhardt"
}
}
The example above is plain JSON. It is perfectly valid, but every API that uses this style invents its own conventions for errors, pagination, relationships, and identifiers.
What JSON:API is
JSON:API is a specification for APIs that use JSON. It defines a media type
(application/vnd.api+json), a document structure, resource objects, relationships,
compound documents, error objects, and query conventions such as include,
fields, sort, page, and filter.
{
"data": {
"type": "articles",
"id": "1",
"attributes": {
"title": "JSON:API paints my bikeshed!"
},
"relationships": {
"author": { "data": { "type": "people", "id": "9" } }
}
},
"included": [
{
"type": "people",
"id": "9",
"attributes": { "name": "Dan Gebhardt" }
}
]
}
The data is separated from its relationships. The article's author is a pointer to
people:9, and the person's attributes are in included. This is what allows a
server to return a graph of related resources without duplicating objects.
Side-by-side comparison
| Aspect | JSON | JSON:API |
|---|---|---|
| What it is | A data format | A specification for APIs |
| Media type | application/json |
application/vnd.api+json |
| Top-level shape | Anything | data, errors, or meta |
| Relationships | Whatever the API chooses | Standard resource linkage |
| Related objects | Nested or repeated | included compound documents |
| Errors | Custom | Standard errors array |
| Pagination / filtering | Custom | Conventions such as page, filter, sort |
| Best for | Small or internal payloads | Consistent, documented APIs |
Can a JSON parser read JSON:API?
Yes — syntactically, a JSON:API document is ordinary JSON, so any JSON parser can read it. What a parser cannot do is interpret it. To display a JSON:API response you also need to:
- separate primary
datafromincluded; - resolve relationship linkage by
typeandid; - detect cycles and missing targets;
- understand
errors,links, andmeta.
That interpretation layer is exactly what a JSON:API viewer provides. A formatter shows the syntax; a viewer shows the graph.
When to use JSON:API
JSON:API is a strong fit when:
- multiple teams or clients consume the same API and need shared conventions;
- responses contain related resources that would otherwise be duplicated or require extra requests;
- you want standard error objects, pagination, sorting, filtering, and sparse fieldsets;
- you want clients and servers in different languages to agree on the contract.
Plain JSON may be simpler when:
- the endpoint is small, internal, or short-lived;
- the payload is a single object with no relationships;
- you control every client and do not need a shared specification.
Neither choice is inherently better. JSON:API trades some up-front structure for consistency at scale. The cost is that raw responses are harder to read by hand — which is why tooling matters.
Frequently asked questions
Is JSON:API the same as JSON?
No. JSON is a general data format. JSON:API is a specification for building APIs in JSON,
defining resource objects, relationships, compound documents, errors, pagination, and the
application/vnd.api+json media type.
Can I use a normal JSON parser for JSON:API?
Yes, the syntax is ordinary JSON. But a parser only gives you the raw object. To use a JSON:API document you must also resolve type and id linkage against included resources and follow the specification's structure.
When should I use JSON:API instead of plain JSON?
JSON:API is a good fit when you want a consistent, documented API across teams, built-in relationship handling, compound documents, standard errors, and conventions for filtering and pagination. Plain JSON is simpler for small or internal endpoints.
See the difference in a real document
Load a JSON:API response and expand its relationships.