JSON is everywhere — APIs, config files, package.json — and it breaks in the most annoying ways. Here are the 5 errors I see most often, and the fastest ways to find and fix them without installing anything.
1. Trailing commas
{"name":"Sujal","city":"Jaipur",}
That comma after "Jaipur" kills the whole file. JSON does not allow trailing commas, period. Delete it.
2. Single quotes instead of double quotes
{'name':'Sujal'}
Looks fine, is not JSON. Keys AND string values must use double quotes:
{"name":"Sujal"}
3. Unquoted keys
{name:"Sujal"}
Valid JavaScript object, invalid JSON. Quote every key.
4. Comments
{//userdetails"name":"Sujal"}
JSON has no comments. If you need them, use JSONC in your editor — but strip them before sending to an API.
5. NaN, Infinity, undefined
{"score":NaN}
These are JavaScript things, not JSON things. Use null or a number.
The fastest ways to validate
Browser console (zero setup): paste your JSON into JSON.parse('...'). The error message tells you the exact character position where it broke. That's usually enough.
Python (already on most machines):
echo'{"a":1,}' | python3 -m json.tool
It pretty-prints valid JSON and points at the error for invalid JSON.
jq (if you live in the terminal):
echo'{"a":1}' | jq .
Formatting: pick one style and stick to it
2-space indent is the most common. Tabs are fine too. What matters is consistency — mixed indentation makes diffs unreadable and code reviews painful.
Four fixes: quotes, keys, trailing commas, and it's done.
I got tired of switching between five different sites for this kind of work, so I built BulkTextKit — 15 free text tools in the browser, including a JSON formatter/validator that points at the exact error. Pro (batch processing, presets, CSV export) is $19: https://bulktextkit.gt.tc
Top comments (1)
Subscribe
Some comments may only be visible to logged-in visitors. Sign in to view all comments.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Top comments (1)
Some comments may only be visible to logged-in visitors. Sign in to view all comments.