A JSON formatter takes minified or malformed JSON and returns it indented, validated and readable. Its more useful job is the second one: telling you precisely where a document breaks, which is rarely obvious when everything is on one line.
What valid JSON allows
| Rule | Valid | Invalid |
|---|---|---|
| Keys must be double-quoted strings | {"a": 1} | {a: 1}, {'a': 1} |
| Strings use double quotes | "text" | 'text' |
| No trailing commas | [1, 2] | [1, 2,] |
| No comments | — | // note |
| Numbers are plain | 1.5, -2e10 | 01, NaN, Infinity, 0x1F |
| Literals are lowercase | true, null | True, NULL |
The absence of comments and trailing commas is the most common frustration, because both are legal in JavaScript. JSON is deliberately a strict subset — it is a data interchange format, not a configuration language, though it is widely misused as one.
The errors you will actually hit
- Trailing comma after the last element, usually left behind when deleting an entry.
- Unescaped characters in strings. A literal double quote, backslash, tab or newline must be escaped as
\",\\,\t,\n. Windows file paths break constantly for this reason. - Single quotes, copied from Python or JavaScript.
- A BOM or stray whitespace before the opening brace, invisible in most editors.
- Truncated response — the document simply stops, usually because a request was cut short rather than because the JSON is wrong.
Reading the error position
Parsers report a character offset or line and column. That position is where parsing failed, which is often after the actual mistake — a missing closing brace is reported at the end of the file, not where the brace should have been. Formatting first usually makes the real problem visible, because correct indentation exposes the point where nesting stops matching.
Escaping and Unicode
JSON is Unicode by definition, and UTF-8 in practice. Non-ASCII characters can appear literally or as \uXXXX escapes; both are valid, and the escaped form is safer through pipelines with uncertain encoding handling. Characters outside the Basic Multilingual Plane, including most emoji, require a surrogate pair of two escapes — which is a common source of mangled output when strings are truncated by byte count rather than character count.
Formatted or minified
| Use | Form |
|---|---|
| Debugging, code review, documentation | Formatted, two-space indent |
| Files under version control | Formatted — one change per line makes diffs readable |
| API responses, network payloads | Minified — whitespace is pure overhead |
| Configuration humans edit | Formatted, with keys ordered logically |
A note on trust
This formatter runs entirely in your browser — the text you paste is parsed locally and never transmitted. That matters more than it sounds: JSON payloads routinely contain API keys, tokens, personal data and internal identifiers, and pasting them into a server-side tool sends all of it to a third party. Before using any online formatter on production data, check whether it processes locally.