Format API Response
This example shows how the formatter handles nested API responses with objects and arrays, making them easy to read.
Indent:
Switch tool:
Try:
Valid JSON
192 characters
Click nodes to toggle
{ "status": "success", "data": { "user": { "id": 123, "name": "John Doe", "email": "john@example.com" }, "posts": [ { "id": 1, "title": "Hello World" }, { "id": 2, "title": "Second Post" } ] }, "meta": { "total": 2, "page": 1 }}How it works
- Paste your JSON — it validates and formats automatically
- Invalid JSON shows error details with line/column position
- Choose 2 or 4 space indentation
- Copy or download the formatted result
Code Examples
Here's how to achieve this in different programming languages:
1// Format JSON with 2-space indentation2const input = `{"status":"success","data":{"user":{"id":123,"name":"John Doe","email":"john@example.com"},"posts":[{"id":1,"title":"Hello World"},{"id":2,"title":"Second Post"}]},"meta":{"total":2,"page":1}}`;3const formatted = JSON.stringify(JSON.parse(input), null, 2);4console.log(formatted);56// Output:7// {8// "status": "success",9// "data": {10// "user": {11// "id": 123,12// "name": "John Doe",13// "email": "john@example.com"14// },15// "posts": [16// {17// "id": 1,18// "title": "Hello World"19// },20// {21// "id": 2,22// "title": "Second Post"23// }24// ]25// },26// "meta": {27// "total": 2,28// "page": 129// }30// }
More JSON Examples
Format package.json
Format a Node.js package.json configuration file.
Format Config JSON
Format application configuration files with nested settings.
Format Nested JSON
Format complex deeply nested JSON structures with multiple levels.
Format GraphQL Response
Format GraphQL API response data with complex structures.