How to use the JSON formatter
- Paste JSON into the input box, or drag a
.jsonfile onto it. Use “Load sample” to try the tool first. - The text is checked as you type. Valid JSON appears formatted on the right with line numbers. Files over 200 KB wait until you press Format, and the limit is 10 MB.
- Choose 2 spaces, 4 spaces or tabs, and tick “Sort keys” to order object properties alphabetically.
- Press “Minify” to remove all optional whitespace, for example before putting JSON in a config value or an HTTP header.
- Copy the result or download it as a file.
How validation and error finding work
The tool uses its own strict parser that follows the JSON grammar in RFC 8259 and stops at the first rule broken. Browsers word their built-in errors differently (Chrome reports a character position, Firefox a line and column, Safari often neither), so a dedicated parser gives the same clear message everywhere. It also copies every number exactly as written. The browser’s JSON.parse would round 12345678901234567890 to 12345678901234567000 and print 1.10 as 1.1; here both stay untouched when you beautify, minify or sort keys.
Worked example
This object was copied from a JavaScript file:
{
"plan": "pro",
"seats": 5,
}
JavaScript allows the comma after 5, but JSON does not. The status bar reads Line 4, column 1 with the reason “Trailing comma before } is not allowed in JSON”, and line 4 is highlighted. Delete the comma and the formatted result appears at once.
The mistakes that break JSON most often
- Trailing commas after the last item, common when copying from JavaScript.
- Single quotes around keys or strings. JSON only accepts double quotes.
- Unquoted keys such as
{name: "Ana"}. - Python or SQL literals like
True,NoneorNULLinstead oftrueandnull. - Comments. JSON has no comment syntax; JSONC and JSON5 do, but standard parsers reject them.
- Raw line breaks inside strings, which must be written as
\n.
Key features
- Exact line and column for every syntax error, with a readable reason.
- Large IDs and long decimals are kept digit for digit, with a note when JavaScript could not store them.
- Beautify with 2 spaces, 4 spaces or tabs; minify to one line.
- Optional alphabetical key sorting, which makes two JSON files easy to compare.
- Counts keys, nesting depth and the size before and after formatting.
- Runs locally, so API keys and customer data in the payload stay private.
Practical use cases
Reading API responses. Paste a one-line response from a log or browser network tab to see its structure. Sorting keys helps when two responses need comparing side by side.
Fixing configuration files. Tools such as package.json, tsconfig.json and many CI settings fail to load on a single stray comma. The line and column point straight to it.
Shrinking payloads. Minifying a pretty-printed document often removes 15% to 30% of its size, which matters for local storage limits and large API requests.