JSON Formatter & Validator
Format, minify and validate JSON, with the line and column of any syntax error and a plain explanation of what is wrong.
{
"name": "BucketWP",
"tools": [
"json",
"base64"
],
"free": true
}
Output is valid and updates as you type.
Fix the highlighted fields to update the output.
Paste JSON to format, minify or check. Syntax errors come back with a line, a column and a plain explanation instead of the browser’s own wording.
How to use
- Paste the JSON. Nothing leaves the tab, which matters when the document is an API response with real data in it.
- Pick the style. Two spaces is the common default; tabs suit a codebase that already uses them; minified is for shipping.
- Sort the keys when you are comparing two documents. The same data with keys in a different order diffs cleanly once both sides are sorted.
- If it fails, read the line and column. The three usual causes are a trailing comma, single quotes and comments, and each is named in the error.
- Copy or download the result.
Example
Sorting makes two responses comparable:
{"b":1,"a":{"d":1,"c":2}}
becomes
{"a":{"c":2,"d":1},"b":1}
Sorting is recursive, so nested objects line up too. Arrays keep their order, because order is meaningful in an array.
Pitfalls
- JSON has no comments.
//and/* */are JSON5 or JSONC, and they have to be stripped before a JSON parser will accept the document. - A trailing comma before
}or]is valid JavaScript and invalid JSON. It is the single most common error in a hand-edited file. - Strings use double quotes. Single quotes are JavaScript, not JSON.
NaN,Infinityandundefinedare not JSON values. A serializer that emits them produces something no parser will read back.- Numbers larger than 2^53 lose precision when parsed into JavaScript. A 64 bit ID should be a string in the document.
- Duplicate keys are not an error. The last one wins, silently, which is how a config change stops having any effect.
- Formatting changes whitespace only. If a signature or a hash was computed over the original bytes, the formatted version no longer matches it.
- Sorting keys changes the byte order of the document. Do it for comparison, not before signing.
Compatibility
Parsing follows RFC 8259, which is what JSON.parse implements: UTF-8, double quoted strings, no comments and no trailing commas. Formatting uses the standard serializer, so key order is preserved unless you ask for sorting. The tool runs entirely in your browser and handles documents up to 100,000 characters.