JSON formatter
Processed in your browser · nothing is uploaded
Formats JSON with the indent you choose, and tells you exactly where it broke if it will not parse. Line and column, not just "invalid".
How to use the json formatter
Almost every rejection comes down to one of three things, and all three are valid JavaScript, which is why they slip through. A trailing comma after the last element is fine in JS and illegal in JSON. Single quotes are fine in JS and illegal in JSON: strings must use double quotes. Unquoted keys are fine in JS and illegal in JSON. Two rarer causes are worth knowing: a byte order mark at the start of a file, which is invisible and breaks the parse on the very first character, and NaN or Infinity, which JavaScript produces happily and JSON cannot represent at all.
Questions
The three usual causes are a trailing comma after the last item, single quotes instead of double, and unquoted keys. All three are valid JavaScript and none is valid JSON.
No. JSON has no comment syntax. JSON5 and JSONC add them, but neither is JSON and a standard parser rejects both.
Usually a byte order mark. An invisible character some editors write at the start of a UTF-8 file. Save without a BOM.
Two spaces is the common default. It affects readability only; the parsed data is identical.
No. Parsing and formatting happen in your browser, which matters when the JSON is an API response with real data in it.
So two documents can be diffed meaningfully. Key order means nothing in JSON and everything to a text diff.