JSON is everywhere: API responses, configuration files, app settings, data exports. It is also strict. One stray comma and a whole file is rejected with an error like Unexpected token } in JSON at position 214, which tells you where the parser gave up but not always what went wrong. Almost every JSON error comes from the same short list of mistakes. Learn them once and you will spot them in seconds.
What valid JSON looks like
A JSON document is a single value: an object in curly braces, an array in square brackets, a string, a number, true, false or null. Objects hold "key": value pairs separated by commas. Keys are always strings in double quotes. That is nearly the whole format, and the strictness is the point: any program in any language can read it the same way.
1. Trailing commas
{"name": "Asha", "city": "Pune",}
The comma after the last item is allowed in JavaScript, and many editors add it, but JSON forbids it. The parser reaches the closing brace while expecting another key. Remove the final comma in every object and array.
2. Single quotes
{'name': 'Asha'}
JSON strings and keys must use double quotes. Single quotes are a very common slip when copying from Python or JavaScript code. Replace them with double quotes, taking care with apostrophes inside text: "Asha's notes" is fine inside double quotes.
3. Keys without quotes
{name: "Asha"}
Valid in JavaScript, invalid in JSON. Every key needs double quotes: {"name": "Asha"}.
4. Missing commas
{"name": "Asha" "city": "Pune"}
Easy to miss when adding a line in the middle of a file. The error usually points at the start of the next key, so look at the end of the line just before the position in the message.
5. Comments
{"debug": true // turn off in production}
Standard JSON has no comments at all, neither // nor /* */. Some tools accept comments in their own config files (formats such as JSONC or JSON5), but a strict parser will not. Remove them, or store the note as a value: "_note": "turn off in production".
6. Values JSON does not have
{"total": NaN, "next": undefined, "big": Infinity}
JSON has no undefined, NaN or Infinity. Use null, or leave the key out. Numbers also cannot have leading zeros (007), a leading plus sign or a trailing decimal point (5.). Write 7, 5 or 5.0.
7. Unescaped characters inside strings
A string cannot contain a raw line break or tab, and a double quote or backslash inside it must be escaped. Write \n for a new line, \" for a quote and \\ for a backslash. Windows paths are a classic trap: "C:\Users\asha" must be written "C:\\Users\\asha".
Less obvious causes
- Curly "smart" quotes. Copying from a word processor, chat app or web page can turn straight quotes into curly ones that look almost the same. JSON only accepts the plain straight double quote.
- A hidden byte-order mark. Some Windows editors put an invisible character at the very start of a file, and some parsers then fail at position 0. Save the file as UTF-8 without BOM.
- An HTML page instead of JSON. If an API returns an error page, parsing fails on the first character,
<. The "JSON" is really HTML; check the request instead of the data. - Two documents in one. Two objects one after the other,
{...}{...}, are not valid JSON. Wrap them in an array, or use one object per line (a format called JSON Lines) if your tool expects that.
Reading the error message
Error messages differ between browsers and languages, but most give a position, a character count from the start, and newer ones give a line and column too. The real mistake is usually just before that point: the parser stops when it meets something that cannot come next, which is often one step after the actual slip. A missing comma at the end of line 7 is reported at the first character of line 8.
The fastest way to find it is to format the JSON with one item per line. Errors that hide in a single long line become obvious when every key has its own line.
Preventing JSON errors
- Generate JSON with code, using your language's own JSON functions, rather than building it by joining strings.
- Validate before you commit or deploy configuration files. A broken config file can take a whole app down.
- Keep sensitive data out of online validators that upload what you paste. API keys and customer data in a JSON file are as private as the file itself.
Paste your JSON into the JSON Formatter and Validator. It points to the line and column of the first error and formats valid JSON so it is easy to read. It runs in your browser, so whatever you paste stays on your device. If your JSON holds HTML, the HTML Escape tool helps with the characters that need care.



