If your browser console (or Node terminal) showed something like:
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
you’re looking at Firefox’s version of this error. In Chrome, the same problem usually shows up as Unexpected token X in JSON. Different wording, same root issue: at some point in the string, JSON.parse() ran into a character that doesn’t make sense in valid JSON syntax at that position.
The key difference from the “position 0” error is that this one can happen anywhere in the string, not just at the start. The message usually gives you the exact line and column, which makes debugging a lot easier.
The most common causes
1. Single quotes instead of double quotes
JSON requires double quotes for both keys and string values. Single quotes aren’t valid, even though plain JavaScript accepts them.
// javascript
// Invalid as JSON
JSON.parse("{'name': 'test'}");
// Valid
JSON.parse('{"name": "test"}');
Notice the outer string can use single quotes (that’s just JavaScript syntax), but the JSON content inside it needs double quotes.
2. Trailing comma
// javascript
// Invalid
JSON.parse('{"a": 1, "b": 2,}');
// Valid
JSON.parse('{"a": 1, "b": 2}');
Unlike JavaScript, which tolerates a trailing comma in objects and arrays, JSON does not.
3. Unquoted keys
// javascript
// Invalid
JSON.parse('{name: "test"}');
// Valid
JSON.parse('{"name": "test"}');
In plain JavaScript you can write {name: "test"} without issues. In JSON, every key needs to be wrapped in double quotes.
4. Comments inside the JSON
// javascript
// Invalid
JSON.parse(`{
"name": "test" // this is a comment
}`);
JSON doesn’t support comments, period. If you’re working with a .json file that does have comments (like some tsconfig.json files allow), that only works because the tool reading that specific file has a lenient parser. It’s not standard JSON.
5. JavaScript-specific values that don’t exist in JSON
// javascript
// Invalid
JSON.parse('{"value": undefined}');
JSON.parse('{"value": NaN}');
JSON.parse('{"date": new Date()}');
// Valid
JSON.parse('{"value": null}');
undefined, NaN, functions, and Date objects don’t exist in JSON. The closest equivalent you have is null.
How to debug it quickly
The error message itself already helps: “line 1 column 15”, for example, tells you exactly where to look. But if the string is large and hard to inspect manually, paste it into a validator that points out the exact position visually, like JSON Validator, instead of counting characters by hand.
Quick checklist
- Are all keys wrapped in double quotes?
- Are all string values wrapped in double quotes (not single)?
- No trailing comma before
}or]? - No comments inside the JSON?
- No
undefined,NaN, or other JavaScript-only values?