Developers

How to read JSON errors, and fix the seven most common ones

Trailing commas, single quotes, comments, missing brackets and more: the seven JSON syntax errors we see most often, what the error means and how to fix each one.

Why JSON is so strict

JSON looks like JavaScript, but it is a much smaller language with no exceptions. Things JavaScript tolerates, such as comments, trailing commas or single quotes, make a JSON file invalid. Error messages also tend to point at the place where the parser *noticed* the problem, which is often just after the real mistake.

Paste the text into JSON Formatter & Validator: it shows the line and column, a pointer under the exact character, and a plain-language explanation of what is wrong.

1–3: commas, quotes and keys

1. Trailing comma. The most common error of all.

{"a": 1, "b": 2,} → {"a": 1, "b": 2}

Remove the comma before } or ]. It often appears after deleting the last item of a list.

2. Single quotes. JSON strings and keys need double quotes.

{'name': 'Kim'} → {"name": "Kim"}

3. Unquoted keys. Allowed in JavaScript objects, not in JSON.

{name: "Kim"} → {"name": "Kim"}

4–5: brackets and commas between values

4. A missing closing bracket. The parser reaches the end of the text while still inside an object or array, so the error appears on the very last line even though the missing } or ] belongs somewhere earlier. Formatting helps here: once the text is indented, the place where the structure goes wrong is usually easy to see.

5. A missing comma between two values, often after copying lines from two places:

["red" "blue"] → ["red", "blue"]

6–7: comments and JavaScript values

6. Comments. // note and /* ... */ are not allowed. Remove them, or move the information into a field such as "_comment": "..." if you control the format.

7. JavaScript-only values. undefined, NaN, Infinity and functions don’t exist in JSON. Use null, a number, or a string instead. Also watch numbers: leading zeros (007), plus signs (+5) and trailing dots (5.) are invalid.

Less common, but confusing

  • A line break inside a string. Strings can’t span lines; write \n instead.
  • Invalid escapes such as \d or a Windows path like C:\Users. Inside a string, a backslash must be doubled: C:\\Users.
  • Extra text after the JSON, for example two objects pasted one after the other, or log text after the closing brace.
  • Invisible characters copied from chat apps or word processors, such as curly quotes (“ ”) instead of straight ones (").

A quick workflow

Paste, read the message, fix the character the pointer shows, and run it again: one error at a time is usually fastest, because one mistake often hides others. Once the JSON is valid, format it and compare it with a known-good version in Text & Code Diff Checker to see what really changed.

The formatter runs in your browser, so you can paste API responses that contain tokens or customer data without sending them to a third-party server.

Tools in this guide