JSON is the most common data format on the internet. It is returned by almost every API, used in configuration files, and embedded in applications from web browsers to mobile apps. Yet raw JSON from an API or a log file is often compressed into a single unreadable line. A JSON formatter turns that wall of characters into a clean, indented structure you can actually understand in seconds.
JSON (JavaScript Object Notation) is a lightweight text-based format for representing structured data. It was derived from JavaScript object syntax but is now completely language-independent — parsers exist in every major programming language.
JSON supports exactly six data types:
"hello" — must use double quotes42 or 3.14 or 1.5e6true or false (lowercase)null[1, 2, 3]{"key": "value"}A JSON document must have exactly one root value — an object, array, or any of the scalar types above.
Consider this API response:
{"user":{"id":1042,"name":"Sarah Chen","email":"s.chen@example.com","roles":["admin","editor"],"lastLogin":"2026-05-28T09:14:33Z"}}
After formatting:
{
"user": {
"id": 1042,
"name": "Sarah Chen",
"email": "s.chen@example.com",
"roles": ["admin", "editor"],
"lastLogin": "2026-05-28T09:14:33Z"
}
}
The structure becomes immediately visible. You can see the nesting, count the fields, and spot relationships between values at a glance. Formatted JSON is dramatically easier to debug and review than minified JSON, even for small payloads.
Use Minify to produce the most compact single-line version — useful before inserting JSON into code or a config file where whitespace increases size. Use Validate to check whether a piece of JSON is syntactically valid without modifying it.
Trailing commas — the most common mistake
// INVALID
{"name": "Alice", "age": 30,}
// ^ trailing comma not allowed
// VALID
{"name": "Alice", "age": 30}
JavaScript and most modern languages allow trailing commas in objects and arrays. JSON does not. The specification is strict, and parsers will reject it.
Single quotes instead of double quotes
// INVALID
{'name': 'Alice'}
// VALID
{"name": "Alice"}
JSON requires double quotes for both keys and string values. Single quotes are JavaScript syntax, not JSON syntax.
Unquoted keys
// INVALID (JavaScript object literal syntax, not JSON)
{name: "Alice"}
// VALID
{"name": "Alice"}
Undefined values
// INVALID — undefined does not exist in JSON
{"value": undefined}
// VALID alternatives
{"value": null} // or omit the key entirely
Comments
// INVALID — JSON has no comment syntax
{
// user details
"name": "Alice"
}
JSON intentionally has no comment syntax. If you need comments in config files, consider JSONC (JSON with Comments) or YAML instead.
JSON largely replaced XML for APIs and data interchange because it is more compact, easier to read, and maps directly to data structures in programming languages. A rough comparison:
For most web APIs created after 2010, JSON is the default. XML remains common in enterprise software (SOAP services, Microsoft Office formats, configuration in Java ecosystems like Spring and Maven).
Does the formatter send my JSON to a server?
No. All formatting, minifying, and validation runs in your browser using JavaScript's built-in JSON.parse() and JSON.stringify() functions. Your data is never transmitted anywhere.
What does the error message tell me?
The exact error from JSON.parse() is shown, which usually includes the position of the problem — for example "Unexpected token , in JSON at position 42". Count characters from the start of your JSON (including whitespace) to find the exact problem location.
Is JSON5 the same as JSON?
No. JSON5 is a superset of JSON that allows trailing commas, single quotes, comments, and other JavaScript-friendly syntax. It is useful for config files but is not standard JSON and will be rejected by most parsers. This tool validates standard JSON only.
Use our free JSON Formatter tool — works in your browser, nothing to install.
JSON Formatter — Free