JSON (JavaScript Object Notation) is the most common data interchange format on the web. But raw JSON from APIs is often minified — no whitespace, no line breaks — making it nearly impossible to read. A JSON formatter adds indentation and line breaks to make the structure visible.
What is JSON?
JSON is a lightweight text format for representing structured data as key-value pairs, arrays, and nested objects. Every modern API, configuration file, and database export uses JSON.
{"name":"Alice","age":30,"roles":["admin","editor"]}
Formatted, this becomes:
{
"name": "Alice",
"age": 30,
"roles": [
"admin",
"editor"
]
}
Common JSON errors
| Error | Cause |
|---|---|
| Unexpected token | Trailing comma, missing quote |
| Unexpected end of JSON | Unclosed bracket or brace |
| Property names must be strings | Using single quotes instead of double |
| Invalid escape character | \n instead of \\n in strings |
How to format JSON online
- Go to JSON Formatter
- Paste your JSON into the input panel
- The formatted output appears instantly in the right panel
- Use Minify to compress it back for production use
JSON vs JavaScript object literals
JSON is stricter than JavaScript:
- All property names must be double-quoted strings
- No trailing commas allowed
- No comments allowed (
//or/* */) - No
undefined,function, orDatevalues (use strings for dates)
Validating API responses
When debugging API calls, paste the raw response body into the formatter. If there's a syntax error, the tool will highlight the line and describe the problem. This is faster than reading error stack traces in code.
Minifying JSON for production
Minified JSON removes all whitespace, reducing file size by 20–40%. Use minify mode when embedding JSON in code, configuration files shipped with apps, or API responses where bandwidth matters.