JSON Formatter & Beautifier
Pretty print JSON with 0-8 spaces or tabs, minify it, or sort object keys recursively. Syntax errors are reported with line and column.
Result
Press “Run” to see the result.
Send a JSON document in json (preferably as a string) or as a raw text/plain body, and get the formatted text back in result with its length in characters. By default the output is indented with 2 spaces; set indent to a number from 0 to 8 or to tab, or use minify=true to remove all whitespace.
With sort_keys=true the keys of every object are sorted alphabetically at all depths, which makes diffs and hashes of JSON stable. Arrays keep their order.
If the input is not valid JSON the response is valid: false with a parse_error (message, position, line and column when available) instead of an HTTP error. The request body is limited to 5 MB.
Use this in your code
curl -X POST "https://apibox.io.vn/v1/json-format" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"json":"{\"b\":2,\"a\":{\"d\":[1,2],\"c\":true}}","sort_keys":true}'const res = await fetch('https://apibox.io.vn/v1/json-format', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"json": "{\"b\":2,\"a\":{\"d\":[1,2],\"c\":true}}",
"sort_keys": true
}),
});
const data = await res.json();
console.log(data);import requests
res = requests.post(
"https://apibox.io.vn/v1/json-format",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"json": "{\"b\":2,\"a\":{\"d\":[1,2],\"c\":true}}", "sort_keys": True},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/json-format');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => '{"json":"{\\"b\\":2,\\"a\\":{\\"d\\":[1,2],\\"c\\":true}}","sort_keys":true}',
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));API documentation → Get a free API key
FAQ
How do I minify JSON?
Send minify=true. The result has no spaces or line breaks.
Can I indent with tabs?
Yes, set indent=tab. Numbers from 0 to 8 set the number of spaces (default 2).
What happens with invalid JSON?
The response is {"valid": false, "parse_error": {...}} with the error message and, when available, the position, line and column.