JSON Formatter & Validator
Pretty-print, minify, and validate JSON — right in your browser.
Formatted JSON appears here.
About JSON Formatter
A JSON formatter online pretty-prints and validates JSON so it's readable and correct. Paste your JSON, pick an indent (2, 4, tab, or minified), and it beautifies or minifies instantly — flagging the exact line and column of any syntax error. Everything runs in your browser, so you can format JSON without uploading it anywhere.
How formatting and validation are the same step
Formatting JSON is really two operations. First the text is parsed into a real data structure — objects, arrays, strings, numbers, booleans, null. Then that structure is written back out with consistent indentation. The useful consequence is that validation comes free: text that cannot be parsed cannot be formatted, so the moment your JSON pretty-prints successfully you know it is syntactically valid.
That is why a formatter is a stricter check than reading the file yourself. Your eyes will happily skip a missing comma on line 340; a parser stops dead at it. It is also why the output is normalised — key order is preserved, but whitespace, line breaks, and indentation are all rewritten from scratch rather than tidied in place.
Reading a syntax error
Parsers report the first position they could not make sense of, which is often one line after the actual mistake. A missing comma at the end of line 11 is reported at line 12, because line 11 was still valid up to its final character — the parser only knew something was wrong when the next key arrived without a separator.
So when you get an error on line 12, look at line 11 first. The usual causes, in rough order of frequency: a trailing comma after the last item in an object or array, single quotes instead of double quotes, an unquoted key, an unescaped double quote inside a string value, and a stray comment. Fix the earliest one and re-run; a single missing character often cascades into several reported errors.
Beautify or minify — which to use
Beautify when a human has to read it: debugging an API response, reviewing a config file in a pull request, or diffing two payloads. Indentation makes nesting depth visible at a glance, and line-per-value output means a version-control diff points at the one field that changed rather than one enormous line.
Minify when a machine has to move it. Stripping whitespace from a typical API payload cuts roughly 15–30% of its bytes before compression, which matters for request bodies, embedded configuration, and anything you are putting in a URL or a header. Do not minify anything a person will maintain by hand — the saving is invisible to users and the cost in readability is not.
JSON rules that catch people out
JSON is a much smaller language than JavaScript, and most errors come from assuming otherwise. Comments are not allowed in either form. Trailing commas are invalid. Keys must be double-quoted strings — not single-quoted, not bare. Values may not be NaN, Infinity, or undefined, all of which JavaScript will happily produce and JSON.stringify will silently turn into null.
Two subtler ones are worth knowing. Duplicate keys are not technically forbidden by the spec, but parsers resolve them inconsistently — most keep the last, so a duplicate silently discards data. And numbers larger than about 9 quadrillion lose precision when parsed into a double, which is why APIs that deal in large IDs usually send them as strings.
Frequently asked questions
- Can I format JSON without uploading it?
- Yes. Formatting, minifying, and validation all happen in your browser — your JSON never leaves your device, so it's safe for private API payloads and configs.
- What's the difference between beautify and minify?
- Beautify (pretty-print) adds indentation and line breaks so JSON is easy to read; minify strips all whitespace to make the smallest possible payload for transport. This tool does both.
- How do I fix an 'invalid JSON' error?
- The validator reports the line and column of the first problem. The usual culprits are trailing commas, single quotes instead of double quotes, unquoted keys, and a missing comma on the line above the reported one.
- Is this a JSON validator too?
- Yes. Any syntax error is caught and pinpointed by line and column as you paste, so the formatter doubles as a JSON validator and syntax checker.
- Can I format a .json file?
- Yes — open the file in any editor, copy its contents in, and format as normal, then copy the result back. There's no upload step and no file size limit imposed by a server, because the work happens on your own device.

