Skip to main content

JSON:API Specification: Format Guide & Implementation

JSON:API is a battle-tested specification for structuring JSON responses from REST APIs. It standardizes resource objects, relationships, links, filtering, sorting, and pagination so that clients and servers speak the same language without custom conventions.

✓ Standardized resource structure ✓ Relationship & sideloading support ✓ Built-in filtering & sparse fieldsets ✓ Client-agnostic pagination links

Core Resource Object Structure

Every JSON:API response wraps resources in a top-level data key. Each resource has a type, id, attributes, and optionally relationships and links:

// GET /articles/1
// Content-Type: application/vnd.api+json

{
  "data": {
    "type": "articles",
    "id": "1",
    "attributes": {
      "title": "JSON:API Explained",
      "body": "JSON:API standardizes your REST responses...",
      "published-at": "2026-01-15T10:00:00Z"
    },
    "relationships": {
      "author": {
        "data": { "type": "people", "id": "9" }
      },
      "tags": {
        "data": [
          { "type": "tags", "id": "2" },
          { "type": "tags", "id": "7" }
        ]
      }
    },
    "links": {
      "self": "/articles/1"
    }
  }
}

Sideloading Related Resources (included)

Avoid N+1 requests by including related resources in the same response using the included array. Clients request this with the include query parameter:

// GET /articles/1?include=author,tags

{
  "data": {
    "type": "articles",
    "id": "1",
    "attributes": { "title": "JSON:API Explained" },
    "relationships": {
      "author": { "data": { "type": "people", "id": "9" } }
    }
  },
  "included": [
    {
      "type": "people",
      "id": "9",
      "attributes": { "name": "Vic Chen", "twitter": "@vicdev" }
    },
    {
      "type": "tags",
      "id": "2",
      "attributes": { "name": "api-design" }
    }
  ]
}

Filtering, Sorting & Sparse Fieldsets

JSON:API recommends standard query parameter patterns for common operations. Implementations define the exact filter syntax, but the parameter names are standardized:

# Filter articles by status
GET /articles?filter[status]=published

# Sort ascending by title, descending by published date
GET /articles?sort=title,-published-at

# Sparse fieldsets: only return title and body attributes
GET /articles?fields[articles]=title,body

# Combine: paginate + filter + include author
GET /articles?page[number]=2&page[size]=10&filter[status]=published&include=author

# Response includes pagination links
# {
#   "data": [...],
#   "links": {
#     "first": "/articles?page[number]=1&page[size]=10",
#     "prev": "/articles?page[number]=1&page[size]=10",
#     "next": "/articles?page[number]=3&page[size]=10",
#     "last": "/articles?page[number]=12&page[size]=10"
#   }
# }

JSON:API vs REST vs GraphQL

Feature JSON:API Plain REST GraphQL
Response shape Standardized Custom per API Query-defined
Relationships Built-in + sideloading Manual nesting Native graph
Over-fetching Sparse fieldsets Common problem Eliminated
Learning curve Medium Low High
Caching (HTTP) Full HTTP cache Full HTTP cache POST-based, harder
Client libraries ember-data, jsonapi-js Any HTTP client Apollo, urql
Share this tool: X / Twitter LinkedIn
✓ 60,000+ developers use DevPlaybook ★★★★★ 4.8 / 5 on Gumroad ✓ MIT licensed · Instant download ✓ No login required

Related Products

on Gumroad

You Might Also Need

More Free Tools

JSON Diff Viewer JSON Diff JSON Formatter Pro JSON Path Finder OpenAPI Validator YAML to JSON Converter CSV to JSON Converter JSON ↔ YAML Converter JSON Schema Form Builder Protobuf to JSON Converter CSV JSON Transformer JSON Schema to Zod Converter API Response Mock Generator API Response Time Tester JSON Formatter & Validator JSON Schema Generator JSON to CSV Converter OpenAPI Schema Validator API Mock Server Config Generator TOML to JSON Converter OpenAPI Mock Generator API Test Case Generator API Request Builder API Response Formatter & Analyzer HTTP API Tester JSON to TypeScript Interface package.json Validator & Audit TOML to JSON Converter package.json Generator OpenAI Function Calling Generator API Rate Limit Calculator LLM Cost Calculator Grafana Dashboard JSON Validator AI Prompt Cost Calculator REST API Request Builder LLM Prompt Cost Calculator Mock Data Generator API Response Mocker LLM JSON Schema Builder AI Rate Limit Calculator Grafana Dashboard JSON Builder API Key Generator AI Doc Generator — Pro Tool HTTP Methods Reference HTTP Code Snippet Generator HTTP Status Code Reference HTTP Status Code Reference Interview Question Generator JWT Builder JWT Decoder TOML Validator YAML Validator & Formatter Rate Limiter Tester API Changelog Generator PWA Manifest Generator HTTP Mock Response Builder Fake Data Generator Rate Limit Calculator Biome Config Generator Package Lock Analyzer Feature Flag Config Generator CORS Policy Builder GCP Service Account Key Checker Azure ARM Template Validator Haproxy Config Validator SBOM Generator HTTP Status Code Lookup HTTP Status Code Lookup JWT Debugger Pro Vue Component Generator HTTP Status Code Reference TypeScript tsconfig.json Generator LLM Context Window Calculator LLM Token Counter Chrome Extension Manifest Generator Prompt Token Estimator YAML Validator Pro Mock Service Worker (MSW) API Mocking Guide Pulumi Modern IaC Guide MCP Endpoint Tester MCP Server Config Builder HTML5 Canvas API Playground Token Context Calculator LangGraph Workflow Visualizer AWS IAM Policy Generator GCP Service Account Key Auditor Expo App Config Generator Token Counter & Cost Estimator AI API Rate Limit Calculator LLM Prompt Template Builder NFT Metadata Generator

Enjoying this tool? Get more like it.

Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.

DevPlaybook Pro 7 days free

Unlock AI-Powered Dev Tools

  • ⚡ AI Code Review, Doc Generator & SQL Builder
  • ⚡ All premium templates & early access
  • ⚡ Member discounts on Gumroad products
Start Free Trial →

$9/mo after trial · Cancel anytime

Want the full toolkit?

Get DevPlaybook Pro

Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.

$79
$241 separately Save $162 (67% off)
Get DevPlaybook Pro — $79 →

MIT licensed · Instant download · No subscription

See what's included → Browse all deals →

Frequently Asked Questions

What is the JSON:API specification?▼

JSON:API is a standardized specification for building APIs in JSON. It defines exactly how resources, relationships, errors, and metadata should be structured in request and response bodies. By following a shared convention, clients and servers can interoperate without per-API custom documentation for basic CRUD operations.

What is the required Content-Type for JSON:API?▼

JSON:API requires the Content-Type header to be application/vnd.api+json for both requests and responses. Sending a plain application/json Content-Type header with a JSON:API body is technically non-conformant, though many implementations accept both in practice.

How does JSON:API handle relationships between resources?▼

Relationships are represented in a relationships object on the resource. Each relationship contains a data object with the related resource's type and id. The full related resource data can optionally be included in a top-level included array in the same response, which avoids N+1 requests from the client side.

What is sparse fieldsets in JSON:API?▼

Sparse fieldsets let clients request only specific fields of a resource using the fields[type]=field1,field2 query parameter. This reduces response payload size significantly for resources with many attributes, similar to how GraphQL lets you select specific fields in a query.

How does JSON:API pagination work?▼

JSON:API does not mandate a specific pagination strategy, but it standardizes the link objects returned: first, last, prev, and next. The server decides whether to use page-based (page[number]=2&page[size]=10), cursor-based, or offset-based pagination internally, and communicates navigation via the links object.

Is JSON:API suitable for every project?▼

JSON:API shines in larger applications with complex resource relationships, multiple client types (web, mobile, third-party), or teams that want a strict shared contract. For simple CRUD microservices with a single client, the verbosity of JSON:API may add overhead without proportional benefit. REST without a strict spec or tRPC is often simpler for small internal APIs.