JSON Formatter
Pretty-print, minify and validate JSON, with the line and column of any syntax error.
Results are provided as is, for general information. Check anything important before relying on it. See the Terms of Use.
About this tool
Paste JSON and reformat it with 2- or 4-space indentation, or minify it to a single line for transport. On a syntax error you get the message with the line and column, so a stray comma or missing brace takes seconds to find. Formatting parses and re-serializes the value, so the output is normalized rather than byte-identical to your input.
How it works
Parsed value = JSON.parse(input) Pretty output = JSON.stringify(value, null, 2 or 4) Minified output = JSON.stringify(value)
Paste JSON and choose Pretty for two- or four-space indentation, or Minify to remove formatting whitespace. Parsing validates the input before producing output; it does not repair invalid JSON. Property names and strings need double quotes, and comments and trailing commas are invalid. Everything runs locally in your browser. Re-serialization can change number notation, discard earlier duplicate keys, and round integers beyond JavaScript's safe integer range, so keep identifiers that need exact large values as strings. Syntax-error wording varies by browser; line and column are shown when the parser supplies a location.
| Question | Working | Answer |
|---|---|---|
| Pretty-print {"name":"Ada","active":true} with 2 spaces | Parse the object, then put each property on its own line with two leading spaces. | { "name": "Ada", "active": true } |
| Minify { "items": [1, 2], "empty": null } | Serialize without indentation; retain the array and null value. | {"items":[1,2],"empty":null} |
| Pretty-print {"a":1} with 4 spaces | Select Pretty, then 4 spaces; the property receives four leading spaces. | { "a": 1 } |
| Minify {"a":1,"a":2,"n":1e3}: are duplicate keys and notation preserved? | JSON.parse keeps the last a value; JSON.stringify writes 1e3 as 1000. | {"a":2,"n":1000} |
| Why does {"a":1,} fail? | The comma promises another property, but column 8 contains }. Remove the comma: {"a":1}. | No formatted output. A parser with location information reports: Syntax error at line 1, column 8. The remaining diagnostic text depends on your browser. |
When to use it
Questions
Why did my numbers change?
JavaScript stores numbers as 64-bit floats, so integers above 2^53 - 1 lose precision and trailing zeros vanish (1.50 becomes 1.5). If you carry very large numeric IDs, store them as strings in your JSON.
Are trailing commas allowed?
No. Validation follows the JSON specification strictly — a trailing comma before a closing bracket is an error, as are single quotes, unquoted keys, comments and NaN. Lenient JSON5-style syntax is a different format.
What counts as valid JSON at the top level?
Any single value: an object or array, but also a bare string, number, boolean or null. The tool formatting 42 without complaint is correct behavior, not a bug.
What is the difference between pretty-printing and minifying?
Same JSON, opposite jobs. Pretty-printing adds indentation (2 or 4 spaces here) and line breaks so humans can read and diff the document; minifying strips all of it, which is what you want before sending a payload over the wire or embedding it in a config. Nothing about the data changes in either direction — parse the output and you get an identical value back.
Does formatting change my data?
Only whitespace. The tool parses your input and re-serializes the value, so keys keep their order and the structure is untouched — but the output is normalized rather than byte-identical. The two things that can visibly move are numbers (see the precision note above) and duplicate keys, where JSON.parse keeps the last occurrence and silently drops earlier ones.
How do I fix the syntax error it reports?
The error names the line and column — jump there first. The usual suspects: a trailing comma before a closing bracket, single quotes instead of double quotes, an unquoted key, a comment, or an unescaped quote inside a string. The tool validates and points at the problem; it does not silently repair input, because auto-repair has to guess, and a guess that parses is worse than an error you can see.
How large a file can it handle?
Formatting runs in your browser, so the practical limit is your machine's memory, not a server quota — multi-megabyte documents are fine and nothing is uploaded. Very large files make the text areas themselves sluggish, because the browser has to render what you paste; for a quick structural check of a huge file, a sample or the head of the file usually tells you what you need.