JSON's syntax is strict on purpose — it makes the format unambiguous for machines to parse, but that means one stray comma can break an entire file. Here are the five errors that show up most often, and how to spot them.
1. Trailing commas
Unlike JavaScript object literals, JSON does not allow a comma after the last item in an array or object.
{ "a": 1, "b": 2, }
That trailing comma after 2 is invalid JSON. Remove it.
2. Unquoted or single-quoted keys
Every key in a JSON object must be a string wrapped in double quotes — not single quotes, and not bare identifiers.
{ name: 'Ali' } ❌
{ "name": "Ali" } ✅
3. Using single quotes for string values
String values must also use double quotes. Single-quoted strings are a common carryover from JavaScript or Python, but JSON doesn't accept them.
4. Mismatched or missing brackets
A missing closing } or ] — especially in deeply nested structures — is one of the hardest errors to spot by eye. A formatter that indents your JSON and points at the exact line/column of the failure saves a lot of time here.
5. A trailing comment
JSON has no concept of comments (// like this or /* like this */). If your JSON came from a hand-edited config file that supports comments (like JSONC), strip them before validating as strict JSON.
What does a "JSON input error" message mean?
"JSON input error" is not one fixed message. It is the general name for what a parser reports when it cannot read your text as JSON, and the exact wording depends on the browser or program. Three messages account for most cases:
- Unexpected end of JSON input means the text stopped too soon. The usual causes are a missing closing bracket, brace or quote, a file that was cut off, or an empty string passed to the parser.
- Unexpected token ... in JSON at position N means the parser hit a character it did not expect at that position. Common culprits are a trailing comma, a single quote, an unquoted key or a comment.
- Unexpected token < means the text starts with
<, so what you received is probably an HTML page, such as an error page, instead of JSON.
In every case, the position or line number in the message points at or just after the mistake, so start there and work through the five causes above.
The fastest way to find the error
Rather than scanning by eye, paste the JSON into a validator that reports the exact line and character of the failure. Fix that one spot, re-validate, and repeat — most "broken" JSON files have just one or two real syntax errors, even if they look intimidating at a glance.