JSON looks like a JavaScript object, and that resemblance causes most of its errors. A JSON parser accepts a small, strict grammar and rejects everything else. Here are the seven mistakes that account for most failures, each with its fix.
1. A trailing comma
{ "name": "hammer", "qty": 14, }
The comma after the last item is invalid. Remove it. This is the most common error, usually left behind after deleting the last line of a list.
2. Single quotes
{ 'name': 'hammer' }
Strings and keys must use double quotes. Replace every single-quoted string with a double-quoted one.
3. Keys without quotes
{ name: "hammer" }
JavaScript allows this, JSON does not. Write "name".
4. Comments
JSON has no comment syntax, so // note and /* note */ both break parsing. Delete them, or keep the note in a field such as "_note": "checked on Monday". Some tools accept JSON with comments, often called JSONC, but a standard parser will not.
5. Values JSON does not have
undefined, NaN and Infinity are not valid. Use null or leave the key out. Functions have no JSON form at all. Dates have none either, so store them as text in ISO 8601 form, such as "2026-10-22T09:30:00Z".
6. Numbers written in other styles
Leading zeros (007), a leading plus sign (+5), hexadecimal (0xFF) and a bare trailing point (5.) are all rejected. Identifiers that start with zero, such as postcodes, phone numbers and account numbers, should be strings. Whole numbers above 9,007,199,254,740,991 lose precision in JavaScript, so send very large IDs as strings too.
7. Unescaped characters inside strings
{ "path": "C:\\Users\\sam", "quote": "She said \"done\"", "text": "line one\nline two" }
Inside a string, a double quote, a backslash and any control character such as a newline or tab must be escaped. Write \", \\, \n and \t. A Windows path pasted straight in will fail until each backslash is doubled.
Reading the error message
Browsers report parse errors differently, but most give a position or a line and column. The real mistake is usually just before the reported position, often a comma or quote at the end of the previous line. The Toolhouse formatter shows the parser’s own message beside the input, so you can fix and re-check as you type.
Habits that keep JSON clean
- Validate before pasting into a config file. One bad character can stop an application from starting.
- Format with two-space indentation so changes are easy to read.
- Sort keys when comparing two files. The same data in a different order produces a noisy difference.
- Be aware that duplicate keys are allowed by the grammar, but parsers disagree about them. In JavaScript the last one wins.
Try it yourself: Open the JSON formatter