Menu
Developer · Edit

JSON Formatter

Beautify, indent, and validate JSON instantly. Spot syntax errors and format messy API responses into readable code.

JSON Formatter & Validator

Purpose: Beautify and validate JSON with proper indentation, and instantly see syntax errors.

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

RuleValidInvalid
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 plain1.5, -2e1001, NaN, Infinity, 0x1F
Literals are lowercasetrue, nullTrue, 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

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

UseForm
Debugging, code review, documentationFormatted, two-space indent
Files under version controlFormatted — one change per line makes diffs readable
API responses, network payloadsMinified — whitespace is pure overhead
Configuration humans editFormatted, 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.

FAQ

Frequently Asked Questions

Why does my JSON fail with a trailing comma?
The JSON specification does not allow one, even though JavaScript does. Remove the comma after the final element of any object or array. This is the single most common validation error.
Can I add comments to JSON?
No. The format has no comment syntax. Common workarounds are a dedicated key such as "_comment", or switching to JSON5, YAML or JSONC for files humans edit — though only standard JSON is universally parseable.
Where is the error if the reported position looks fine?
The parser reports where it gave up, not where the mistake is. A missing closing brace is reported at the end of the document. Format the file first — correct indentation usually makes the point of divergence obvious.
How do I include a quote or backslash in a string?
Escape them as \" and \\. Tabs and newlines become \t and \n. Windows file paths need every backslash doubled, which is a frequent source of errors.
Should I format or minify?
Format for anything a human reads or that lives in version control, since line-based diffs become useful. Minify for network payloads, where whitespace is wasted bandwidth.
Is it safe to paste sensitive JSON here?
This tool parses entirely in your browser and transmits nothing. That is not true of every online formatter, so check before pasting anything containing credentials, tokens or personal data into one.
Keep exploring

Related Developer Tools

Browse all Developer tools →