Invalid JSON: The 10 Most Common Errors and How to Fix Them

Published 24 November 2026 · 7 min read

JSON is strict. A file that looks fine to a person can be rejected by a parser because of one stray character, and the error message rarely says what is wrong in plain words. These ten problems account for most failures.

The ten problems

ProblemInvalidFix
1. Trailing comma{"a": 1,}Remove the last comma
2. Single quotes{'a': 1}Use double quotes only
3. Unquoted keys{a: 1}Write "a"
4. Comments// note or /* note */Delete them; JSON has no comments
5. Missing comma{"a": 1 "b": 2}Add a comma between pairs
6. Special valuesNaN, Infinity, undefinedUse null or a string
7. Python valuesTrue, False, NoneUse true, false, null
8. Bad string contentA raw line break or an unescaped quote inside textWrite \n and \"
9. Bad numbers007, .5, 0x1F, +3Write 7, 0.5, 31, 3
10. Extra contentTwo objects in a row, or text after the closing bracketWrap in an array, or see JSON Lines

The invisible ones

Some files fail at position 0 with no visible cause. A byte order mark, a few hidden bytes some editors add at the start of a UTF-8 file, will do that, as will a stray character copied from a web page. Curly quotes from a word processor look like quotes but are different characters. Re-save the file as plain UTF-8 and retype the quotes.

Where the bad JSON comes from

  • JavaScript objects and Python dictionaries printed as text. They look like JSON but use single quotes, unquoted keys or Python constants. Serialize them with JSON.stringify or json.dumps instead of copying the printed output.
  • Config files that allow comments and trailing commas, such as JSONC.
  • Log files and exports with one object per line. That is JSON Lines, not one JSON document; see JSONL vs JSON.
  • Cut-off downloads, where the file simply ends too early and a bracket is missing.

How to find the exact spot

Parsers report a position or a line and column, and the real mistake is usually just before it, since the parser only notices when it meets something unexpected. Paste the text into the JSON formatter: it shows the line and column with the surrounding text, and can repair many of the problems above, listing each change it made so you can check it. For the most common error message, read unexpected token in JSON.

After it is valid

Once the JSON parses, you can compare versions with the JSON Diff tool or check its structure with a schema; see JSON Schema basics.