Published January 2026 • 6 min read
JSON and REST APIs go hand in hand. If you have ever called a web API using fetch(), Axios, or a library like requests in Python, you have almost certainly been sending and receiving JSON. Here is a practical look at how JSON flows through a REST API.
A REST (Representational State Transfer) API is a way for two systems to communicate over HTTP. The client sends requests to defined endpoints (URLs), and the server responds with data — typically formatted as JSON.
Here is what a response from a user API endpoint might look like:
GET https://api.example.com/users/42
{
"id": 42,
"name": "Dinesh N.",
"email": "dinesh@example.com",
"role": "developer",
"createdAt": "2024-03-15T10:30:00Z"
}
When creating or updating resources, you send JSON in the request body:
POST https://api.example.com/users
Content-Type: application/json
{
"name": "Priya Sharma",
"email": "priya@example.com",
"role": "editor"
}
The Content-Type: application/json header tells the server to expect a JSON body.
Well-designed APIs also return errors as JSON, making them easy to handle programmatically:
{
"error": {
"code": 404,
"message": "User not found",
"details": "No user exists with id 99"
}
}
In the browser or Node.js, parsing an API response is straightforward:
const response = await fetch('https://api.example.com/users/42');
const user = await response.json(); // Parses JSON automatically
console.log(user.name); // "Dinesh N."
data, page, and total fields"2024-03-15T10:30:00Z"When debugging API responses, paste the raw JSON into the JSON Pretty formatter on this site to make it readable instantly.