Kit — JSON formatter

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.

Result

The formatted output will appear here.

Input size
Output size
Output lines
Keys total
Array elements
Max nesting
Top-level type

This runs entirely in your browser. Nothing is uploaded.

What this one gets right

A line and a column, always

Browser error messages often carry no position at all — Chrome returns a snippet instead once the input is any real length, and Safari never gives one. This page follows the syntax itself to find the spot, then quotes the line with a caret under the character. Minified JSON — one line, megabytes long — is windowed around the error instead of dumped.

Names the thing JSON forbids

Trailing commas, single quotes, unquoted keys, comments, curly quotes and ideographic spaces from a CJK keyboard. Every one of them is a habit from JavaScript or from a text editor, and "Unexpected token" explains none of them. Whatever is found gets named.

API responses stay on your machine

Most things pasted into a JSON formatter are API responses, and API responses carry bearer tokens, e-mail addresses and order history. Everything here happens in the page; nothing is sent anywhere.

Worth knowing

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 — inelegant, but valid.
The numbers changed when I formattedThey 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, with no network request involved. 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 also mangles every apostrophe inside a string. Showing you where and why is safer than silently rewriting your data.

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.