How to Fix JSON Parse Errors — Find the Exact Line and Column Instantly
Table of Contents
A JSON parse error means your JSON has a syntax problem — and the fastest way to find it is to paste the JSON into a validator that tells you the exact line and column. The WildandFree JSON Formatter does this: paste your broken JSON, see the error highlighted immediately.
Here's how to fix the most common JSON errors you'll run into.
The 6 Most Common JSON Parse Errors
1. Trailing comma
Wrong: {"name": "Alice", "age": 30,}
Right: {"name": "Alice", "age": 30}
JavaScript allows trailing commas. JSON does not. This is the #1 source of JSON errors.
2. Single quotes instead of double quotes
Wrong: {'name': 'Alice'}
Right: {"name": "Alice"}
JSON requires double quotes. Single quotes are JavaScript, not JSON.
3. Unquoted keys
Wrong: {name: "Alice"}
Right: {"name": "Alice"}
Every key in a JSON object must be a quoted string.
4. Comments
Wrong: {"name": "Alice" // this is the user}
Right: Remove the comment entirely.
JSON does not support comments. If you need comments in config files, use JSONC or YAML instead.
5. Unescaped quotes inside strings
Wrong: {"message": "She said "hello""}
Right: {"message": "She said "hello""}
Quotes inside a string value must be escaped with a backslash.
6. Missing commas between items
Wrong: {"name": "Alice" "age": 30}
Right: {"name": "Alice", "age": 30}
Every key-value pair except the last must be followed by a comma.
The Fastest Way to Find a JSON Error
Don't read JSON line by line looking for the error — that takes forever with large files. Instead:
Step 1: Copy the entire JSON (Ctrl+A, Ctrl+C).
Step 2: Paste it into the JSON Validator.
Step 3: Read the error message. It will say something like "Unexpected token , at line 23, column 5" or "Unexpected end of JSON input."
Step 4: Go to that line in your JSON. The error is usually one or two lines above where the parser reports it — the parser notices the problem when it hits an unexpected character, not where the mistake actually is.
For example: if you're missing a closing bracket on line 20, the parser might not notice until it hits line 22 when it encounters a key where it expected the end. The error says line 22, but the fix is on line 20.
Sell Custom Apparel — We Handle Printing & Free ShippingDecoding Cryptic JSON Error Messages
"Unexpected end of JSON input" / "Unexpected EOF"
You're missing a closing bracket or brace somewhere. Count your opening { and closing }, and your opening [ and closing ]. One of those pairs is unbalanced.
"Unexpected token ,"
You have a trailing comma — a comma after the last item in an object or array. Remove it.
"Unexpected token u in JSON at position 0"
The value is undefined. You're trying to parse something that isn't a string — maybe a variable that's undefined, or an empty API response.
"Unexpected token }"
You probably have a missing comma between two items, or an extra closing brace.
"Unexpected string in JSON at position X"
Two string values or two keys are adjacent without a colon or comma between them.
When in doubt, paste the JSON into the validator and let the error message guide you. Fix one error at a time — sometimes fixing the first error reveals a second one.
JSON Parse Errors in Code vs Config Files — Different Causes
In config files (package.json, tsconfig.json, .eslintrc.json):
These are almost always caused by hand-editing. The most common culprits: trailing commas, missing commas when adding a new key, or accidentally introduced single quotes. Use an editor with JSON syntax highlighting and validation (VS Code does this automatically). Or paste the file into the online validator before committing.
In API responses:
If an API returns malformed JSON, it's often because the server sent an HTML error page instead of JSON (403 Forbidden, 500 Internal Server Error, or a Cloudflare error page). Check the Content-Type header — if it says text/html instead of application/json, you're not getting JSON. Handle this in your error handling code before trying to parse.
In copied JSON from documents or messages:
Copy-pasting from PDF, Word, Slack, or email often introduces "smart quotes" (curved double quotes) that look like regular quotes but aren't the ASCII " that JSON requires. Also watch for en-dashes and em-dashes substituted for hyphens. Paste into the validator first.
Try It Free — No Signup Required
Runs 100% in your browser. No data is collected, stored, or sent anywhere.
Open Free JSON FormatterFrequently Asked Questions
Why does my JSON parse error point to the wrong line?
JSON parsers detect errors when they encounter an unexpected character, which is often after the actual problem. If you're missing a closing brace on line 10, the parser might not notice until it hits the next key on line 12 and gets confused. Check a few lines before the reported error location.
How do I fix "Unexpected token < in JSON at position 0"?
This means you received an HTML document (starting with < for a DOCTYPE or HTML tag) instead of JSON. Your API call returned an error page, not data. Check the HTTP status code and the raw response body — you're not getting valid JSON from the server.
Can JSON have undefined values?
No. JSON supports only these value types: string, number, object, array, boolean (true/false), and null. Undefined, functions, and Date objects are not valid JSON values. If you're converting JavaScript objects to JSON, these values will either be omitted or throw an error.

