Almost every invalid JSON file fails for one of nine small mistakes — a trailing comma, a wrong quote, an unclosed bracket. Find yours below, fix the character, and your file will parse. When you wonder why is my json not working, the answer is usually one of nine small mistakes — and this json parse error fix guide names each one, so you can fix the character and watch the file parse.
A quick note before the list: when a parser reports an error position, it is telling you where it gave up, which is usually a character or two after the real mistake. Always look at the token just before the reported position.
Try it now: JSON Formatter & Validator — paste your JSON, find the exact line and column of the error, copy the fixed version. Free, no sign-up, runs in your browser.
1. A trailing comma after the last item
The most common JSON error of all, because JavaScript allows it and JSON does not.
{ "name": "Sara", "role": "editor", }
Fix: delete the final comma.
{ "name": "Sara", "role": "editor" }
The same rule applies inside arrays: [1, 2, 3,] is invalid; [1, 2, 3] is fine.
2. Single quotes instead of double quotes
JSON strings must use double quotes. Single quotes — which many languages accept — are always an error.
{ 'name': 'Sara' }
Fix: swap every single quote for a double quote: { "name": "Sara" }.
3. Unquoted keys
Every key in a JSON object must be a double-quoted string. Writing it bare, JavaScript-style, breaks the file.
{ name: "Sara" }
Fix: quote the key: { "name": "Sara" }.
4. A missing comma between items
The mirror image of mistake 1 — two items run together with nothing between them.
{ "name": "Sara" "role": "editor" }
Fix: add the comma: { "name": "Sara", "role": "editor" }.
5. Comments inside the file
Standard JSON has no comments at all. The // and /* … */ comments you write in code are syntax errors here.
{
// user's display name
"name": "Sara"
}
Fix: delete the comments. If you need notes, keep them in a separate document — or accept that you are writing JSON5 or JSONC, which some tools support but standard parsers (and most APIs) will still reject.
6. Mismatched or missing brackets
Every { needs its } and every [ its ], in the right nesting order. Long files usually break by losing one closer at the end, or by closing an array with a curly bracket.
{ "tags": ["seo", "writing" }
Fix: match each pair. The fastest way to see the structure is to format (pretty-print) the file — indentation makes a wrong bracket obvious. This is also where hand-editing does the most damage; see the workflow at the end of this guide.
7. Values written the JavaScript way
JSON only allows strings, numbers, true, false, null, objects and arrays as values. These all look reasonable and are all invalid:
undefined,NaN,Infinity— not part of JSON.- A bare word as a value:
{ "status": active }— quote it:"active". - Numbers with leading zeros:
0123is invalid. Write123— or"0123"if the leading zero actually matters (as it does in some codes and IDs).
8. Unescaped characters and “smart” quotes inside strings
Two related traps hide inside string values:
- Real line breaks and unescaped quotes. A string cannot contain an actual newline, a raw
"or a lone backslash. Use the escape forms instead:\nfor a newline,\"for a quote,\\for a backslash. - Curly quotes. If the JSON was copied out of Word, a web page or a chat app, its straight quotes may have been silently replaced with typographic ones —
"name"with curly characters is not JSON at all. Retype the quotes in a plain-text editor and the file often heals itself.
9. The file is not one JSON value
Sometimes every line looks fine and the file still fails, because a JSON document must be exactly one top-level value — one object or one array. These files are invalid as a whole:
- Two objects back to back:
{...} {...}(common in log exports). - A file of separate JSON objects, one per line — that’s JSON Lines (
.jsonl), a different format; parse it line by line, not as one document. - Extra text wrapped around the payload: a server name, a timestamp, or a
callback(...)wrapper from an old JSONP endpoint pasted in with the data.
Fix: keep one clean value per file, and strip anything that arrived wrapped around it.
The fastest way to find your error
Reading a long file top to bottom is the slow way. Instead:
- Paste the JSON into a json formatter that validates as it works — ours reports the exact line and column of the problem, in plain English.
- Look at the token just before that position and match it against the nine mistakes above.
- Fix, re-validate, and use the formatted (beautified) view to eyeball the structure before you ship it.
One safety point: API responses often contain keys, tokens and customer data. QuickTextTools’ formatter runs entirely in your browser — nothing you paste is sent to or stored on a server — which is the only kind of online validator you should paste sensitive payloads into.
How to stop breaking JSON in the first place
- Generate it, don’t hand-write it. Every language has a serializer (
JSON.stringify,json.dumps, and equivalents); use it instead of gluing strings together. - Validate where you write. Turn on JSON checking in your editor so errors surface as you type, not at runtime.
- Keep a known-good sample of each API response or config you maintain, and diff against it when something breaks.
- Minify last. Keep files formatted and readable while editing; compress to a single line only at the moment you ship — and validate once more after minifying.
Try it yourself: JSON Formatter & Validator
Invalid JSON FAQs
Why does the error message point at the wrong line?
A parser reports the position where it could no longer make sense of the file, which is typically just after the real problem — the character following a missing comma, for example. When the reported position looks innocent, inspect the token immediately before it; the mistake is almost always there.
Are JSON and JSON5 the same thing?
No. JSON5 is a relaxed extension that allows comments, trailing commas and single quotes. Files written as JSON5 will fail in standard JSON parsers, browsers and most APIs. Unless your specific tool explicitly says it accepts JSON5, write plain JSON.
Can I put comments in JSON if my team agrees to it?
Not in standard JSON — agreement doesn’t change the parser. If your stack genuinely needs comments, use a format designed for it (JSONC in editor settings files, or YAML for hand-maintained config) and convert to strict JSON before anything else consumes the file.
Is it safe to paste an API response into an online validator?
Only into one that runs locally. A validator that uploads your JSON to a server now holds a copy of whatever tokens, keys or customer records were inside it. The QuickTextTools formatter parses everything in your browser, so the payload never leaves your device — check for that property before pasting sensitive JSON anywhere.