Common JSON Errors and How to Fix Them
The mistakes that most often break JSON, such as trailing commas and single quotes, and a quick process for finding and fixing them.
JSON is strict
JSON looks like a JavaScript object, but its rules are tighter. Keys and strings must use double quotes, there are no comments, and the last item in an object or array must not be followed by a comma. Many errors come from copying JavaScript objects or Python dictionaries and expecting them to be valid JSON.
The five most common errors
Trailing commas: a comma after the final item, such as {"a": 1,}.
Single quotes: {'a': 1} is not valid; use double quotes.
Unquoted keys: {a: 1} must be {"a": 1}.
Comments: // and /* */ are not allowed in JSON.
Wrong values: Python's True, False and None, or JavaScript's undefined, are not valid JSON. Use true, false and null.
Find the error quickly
Paste the data into a validator. It will report where parsing failed, and the real mistake is usually on that line or just before it, such as a missing comma on the previous line. Fix one problem at a time and validate again.
Format first, then read
Minified JSON is hard to check by eye. Format it with indentation so that nesting is visible, then look for brackets that do not match. Consistent indentation makes a missing closing bracket easy to spot.
Be careful with real data
Do not paste secrets, tokens or personal data into any online tool unless you are sure how it processes them. Tools that run entirely in your browser do not upload your text, but removing sensitive values first is still good practice.
This guide is general information. Rules differ between institutions, so confirm requirements with your college or the portal you are using.