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.

Enable JavaScript to customise; default output below.

Nothing is uploaded. The parsing happens in this tab.

Style
Live preview formatted.json
{
  "name": "BucketWP",
  "tools": [
    "json",
    "base64"
  ],
  "free": true
}

Output is valid and updates as you type.

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

  1. Paste the JSON. Nothing leaves the tab, which matters when the document is an API response with real data in it.
  2. Pick the style. Two spaces is the common default; tabs suit a codebase that already uses them; minified is for shipping.
  3. 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.
  4. 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.
  5. 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, Infinity and undefined are 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.

Frequently asked questions

Is my data uploaded?
No. The whole thing runs in the browser tab. Nothing is sent anywhere.
Why does my file fail with a trailing comma?
Because JSON does not allow one, even though JavaScript does. Remove the comma before the closing brace or bracket.
Can I format JSON with comments?
Not as JSON. Strip the comments first, or use a JSON5 parser and convert the result.
Does sorting keys change the data?
No. It changes the order keys are written in. Every parser treats the two as equal, but a byte comparison or a signature will not.
Why did my big number change?
JavaScript numbers are doubles, so anything beyond 2^53 is rounded. Keep large identifiers as strings.
Weekly drops

New tools, when there are new tools

One email when something worth using ships. No schedule to fill, so no filler.

Your address goes nowhere else, and one click unsubscribes.