JSON formatter/validator · Guide

Common JSON Mistakes and How to Fix Them

Most "invalid JSON" errors come from a short list of mistakes. Once you recognise them, fixing JSON becomes routine. Here are the ones that trip people up most often.

Trailing commas

JavaScript tolerates a comma after the last array item or object property; JSON does not. A trailing comma is the single most common cause of invalid JSON. Remove it and the input usually parses.

Single quotes and unquoted keys

JSON strings and keys must use double quotes. Single quotes, or keys with no quotes at all, are valid JavaScript object syntax but not valid JSON. Convert them to double quotes.

Comments and special values

JSON has no comments — neither // nor /* */ are allowed. It also rejects JavaScript values like undefined, NaN and Infinity. Strip comments and replace unsupported values before formatting.

Frequently asked questions

How do I find which line is broken?

Paste the JSON into the formatter and read the error message — it reports where parsing failed, which narrows the search to a specific spot.

Ready to try it?

Open the free browser-based JSON formatter/validator and apply what you just read — no sign-up, runs locally.

Open the JSON formatter/validator tool