JSON Formatter Online
Turn unreadable one-liners into clean, indented structure. Or crunch massive files down for production.
Readability Matters
JSON returned from APIs is often "Minified" (one single line) to save bytes. This is great for computers but impossible for humans to debug.
Beautifying (Pretty Printing) adds nested indentation (usually 2 or 4 spaces) so you can clearly see the parent-child relationships in your data.
How to Format JSON in 3 Steps
- Paste Data: Copy your messy, minified JSON string into the input box above.
- Choose Style: Click 2 Spaces (JavaScript standard) or 4 Spaces (Java/Python standard).
- Copy Result: The tool instantly validates and beautifies your code. Click the Green Copy Button to use it.
Why Minify?
Reduce Response Size
Removing whitespace can reduce a JSON payload size by 30-40%. This reduces latency and bandwidth costs for your API.
Automate with cURL
Need to test this JSON against an API? Click "Copy as cURL" to instantly generate a command-line ready request. No more manual escaping of quotes!
Format JSON in JavaScript
Need to format JSON programmatically? Here are the essential code snippets:
Pretty Print (Beautify)
const obj = {name: "John"};
// 2-space indent
JSON.stringify(obj, null, 2);
// 4-space indent
JSON.stringify(obj, null, 4);Minify (Compact)
const obj = {name: "John"};
// No whitespace
JSON.stringify(obj);
// Output: {"name":"John"}Formatting FAQ
Can I format invalid JSON?
No. The formatter must parse the JSON first to understand its structure. If you have syntax errors, try our JSON Validator first.
Is there a file size limit?
Browsers can handle strings up to ~500MB, but for performance, we recommend keeping pastes under 10MB.