JSON Formatter and Validator
Prettify, minify and check JSON, with colour highlighting and error messages that name the line, the column and the actual cause. Numbers keep their exact text, so nothing is quietly rewritten on the way through.
Size
Depth
Keys
Objects / arrays
How to use it
- Paste your JSON on the left. It is checked as you type, so you do not have to press anything.
- Choose Prettify to lay it out, or Minify to strip every optional space.
- If it will not parse, read the message. It gives the line, the column, a caret under the exact character, and what was expected there instead.
- Turn on Fix common mistakes to repair the things people actually paste — comments, trailing commas, single quotes, unquoted keys.
Your numbers come out the way they went in
Almost every online JSON formatter runs your document through JSON.parse and then JSON.stringify. That is a two-line implementation, and it quietly corrupts data.
JSON.parse turns every number into a 64-bit float. So 1.0 comes back as 1, 1e5 becomes 100000, and any integer above 253 is rounded to something near it but not equal to it:
in {"id": 9007199254740993}
out {"id": 9007199254740992}That is a real database identifier turning into a different, valid-looking database identifier. Twitter's API made this famous, and it still bites anyone handling 64-bit IDs, financial amounts or precise decimals. This page parses by hand and keeps the original text of every number and string, so formatting changes the whitespace and nothing else.
The mistakes that stop JSON parsing
| Problem | Looks like | Why |
|---|---|---|
| Trailing comma | {"a": 1,} | The last item may not be followed by a comma. |
| Single quotes | {'a': 1} | JSON has one string delimiter, and it is the double quote. |
| Unquoted key | {a: 1} | That is JavaScript object syntax, not JSON. |
| Comments | { // note | JSON has no comments. Nothing in the standard allows them. |
| Python literals | {"a": True} | JSON uses lowercase true, false and null. |
| NaN or Infinity | {"a": NaN} | Neither is a JSON number, however much JavaScript allows them. |
| Leading zero | {"a": 0123} | A number may not start with a zero unless it is zero. |
| Curly quotes | {“a”: 1} | Usually from a word processor or a chat window. |
| Byte order mark | {"a": 1} | Invisible, and the reason a file that looks fine will not parse. |
Every one of those can be repaired automatically here. The repair works by scanning the text rather than by pattern matching, so it never touches the inside of a string — a // in a URL stays exactly where it is, which is more than can be said for most comment strippers.
Duplicate keys
{"a": 1, "a": 2} is valid JSON. The standard permits it and every parser keeps the last one, so the first value disappears without a sound. It is almost always a mistake — a hand-edited config, or two code paths writing the same field — so this page lists any duplicates it finds and the line each was repeated on. Nothing else about your document changes.
Questions
Is my JSON uploaded anywhere?
No. The parsing happens in your browser. That matters more for JSON than for most formats, because the thing people most often need to format is an API response with real customer records, tokens or internal identifiers in it.
How large a document can it handle?
Several megabytes without trouble. Past about 200,000 characters the result stops being colour-highlighted — one coloured span per token is what makes a browser struggle, not the parsing — but the output is still complete, and Copy and Download still give you everything.
Why does it refuse very deeply nested documents?
Anything past 500 levels is rejected with a message rather than parsed. Beyond that depth a recursive parser runs out of stack and takes the browser tab down with it, which is a far worse outcome than being told no. Real documents are rarely deeper than ten.
What is the difference between prettify and minify?
Only whitespace. Prettify adds line breaks and indentation so a person can read it; minify removes every space that is not inside a string, which is what you want before sending it over a network. The data is identical either way.
Does sorting the keys change anything?
Not to a parser — object properties have no guaranteed order in JSON. It is useful when you want to compare two documents that hold the same data in a different order. Array order is never touched, because that is meaningful.
Can it handle JSON Lines, or several documents at once?
Not as one paste. JSON holds exactly one value, so a file with one object per line is several documents, and you would get an error at the start of the second one. Format them one at a time.
Does it work offline?
Once the page has loaded, yes. Everything it needs is already on your device.