Get to know MDN better
The JavaScript exceptions thrown by JSON.parse() occur when string failed to be parsed as JSON.
JSON.parse() parses a string as JSON. This string has to be valid JSON and will throw this error if incorrect syntax was encountered.
Both lines will throw a SyntaxError:
Omit the trailing commas to parse the JSON correctly:
You cannot use single-quotes around properties, like 'foo'.
Instead write "foo":
You cannot use leading zeros, like 01, and decimal points must be followed by at least one digit.
Instead write just 1 without a zero and use at least one digit after a decimal point:
This page was last modified on Jul 8, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.