JSON formatter and validator
Paste JSON to pretty-print, minify or sort its keys. When it does not parse, you get the line and column, the offending line quoted with a caret under it, and a plain-language note about trailing commas, comments and the other things JSON quietly forbids.
Input
Output
Related tools
All tools- Word & character countCharacters, words, lines and reading time, counted as you type.
- Full-width / half-width converterConvert Japanese text between full-width and half-width, one character class at a time.
- Line toolsRemove duplicate and blank lines, sort, trim and number a list — in one pass.
- CSV ⇄ JSON converterCSV and JSON, both ways — quoted commas and line breaks included.
Highlights
- Errors located by line and column
- When JSON does not parse, the syntax is analysed to find the position, and the offending line is quoted with a caret under the character. Minified single-line JSON is windowed around the error rather than dumped in full.
- Common causes are named
- Trailing commas, single quotes, unquoted keys, comments, curly quotes, full-width spaces: when one of these is found, it is named specifically instead of a generic "Unexpected token".
- Nothing is uploaded
- Formatting and validation happen entirely in the page, and nothing you paste is sent anywhere. API responses containing tokens or personal data are fine to use.
How to use it
Paste your JSON
Paste it into the box. Line numbers run down the side, so a reported line is easy to find. The button that inserts a deliberately broken sample is there if you just want to see what it does.
Pick a mode
Pretty, minify or sort keys. In the two pretty modes you can also choose the indent: two spaces, four spaces or a tab. The result appears as soon as something is in the box.
Take the result
Valid JSON is marked OK, and the output can be copied or downloaded. If it does not parse you get the line and column, with the offending line quoted and a caret under the character.
About the JSON format
- Why are trailing commas and comments not allowed?
- JSON grew out of JavaScript syntax but is specified separately (RFC 8259), and the things JavaScript later relaxed were never folded back in. Trailing commas arrived in JavaScript with ES5; JSON never got them, and comments were never in the grammar at all. For config files, people either use a different format (JSONC, JSON5) or a plain `"_comment"` key.
- The numbers changed when I formatted
- They can. `JSON.parse` turns every number into a double, so `1.0` comes back as `1`, and an integer beyond about 19 digits — `12345678901234567890` — is rounded. This is why so many APIs return IDs as strings. If you are moving large IDs around, check them before and after.
- What happens to duplicate keys?
- The last one wins and the earlier ones are gone. That is `JSON.parse` behaviour, not a choice made here — they are lost at read time, before any formatting or sorting happens.
- What is JSON Lines?
- One complete JSON value per line, separated by newlines. It is common for logs and large datasets because you can append a record without rewriting the file and process it a line at a time. The file as a whole is not JSON, so an ordinary parser always rejects it — this tool switches over automatically when every line parses on its own.
Questions
- Is the JSON I paste uploaded?
- No. Parsing, formatting and validation all happen in the page, and what you paste is never sent to a server. Close the tab and it is gone.
- How large an input can it handle?
- No hard limit — it depends on your device. A few megabytes is comfortable. Above roughly 200KB the live formatting switches off and a Format button appears, because re-parsing several megabytes on every keystroke makes typing itself stutter.
- Will it repair broken JSON for me?
- No. Deleting a trailing comma would be safe, but swapping single quotes for double quotes can also mangle apostrophes inside strings. Instead of rewriting anything automatically, it shows the position and the reason.
- Does the line number come from the browser?
- No — leaving it to the browser is why most formatters cannot show one. Chrome returns a snippet instead of a position once the input is any real length, and Safari never includes one. So this page walks the syntax itself to find where the document first breaks, and counts the line and column from there. The explanation ("nothing follows this comma") comes from the same pass; the browser’s own wording is kept below for reference. The formatting is still done by the browser’s standard parser, so the output matches how JSON is read everywhere else.
- What is sorting keys good for?
- Stable diffs. Two files with identical content but different key order produce noise in a comparison; sort both first and only the real differences remain. The order is Unicode code-unit order, so it is the same on every machine.