Common JSON Errors and How to Fix Them

Most JSON errors come from a short list: a trailing comma, single quotes, unquoted keys, comments, or an invisible character at the start of the file. To find yours, paste the JSON into the JSON Formatter & Validator and click Validate. It shows the parser's message and, when the browser reports a position, the line and column of the first problem. Fix that, validate again, and repeat until you see Valid JSON.
Try it now
JSON Formatter & Validator
Loading tool…
Why strict JSON is so picky
JSON looks like JavaScript, but its grammar is much smaller. Keys must be double-quoted strings, values must be one of six types (string, number, object, array, true/false, null), and nothing else is allowed. No comments, no trailing commas, no undefined. A parser stops at the first character that breaks the grammar, which is why you fix errors one at a time.
Error wording depends on the parser. The same trailing comma gets one message in Chrome, another in Firefox, and another in Python's json module. Rely on the position and treat the message as a hint.
1. Trailing commas
The most common one, especially after you delete the last item in a list.
{
"name": "Ada",
"roles": ["admin", "editor",],
}
Fix: remove the comma after the last element of every array and object.
{
"name": "Ada",
"roles": ["admin", "editor"]
}
Watch for this in hand-edited config files like package.json. Your editor may be lenient (VS Code treats some files as JSONC), but npm and other tools still need strict JSON.
2. Single quotes
{ 'name': 'Ada' }
JSON strings and keys need double quotes. Fix:
{ "name": "Ada" }
If a string contains a double quote, escape it: "She said \"hi\"". An apostrophe inside a double-quoted string is fine: "Ada's laptop".
3. Unquoted keys
Copying a JavaScript object literal usually produces this:
{ name: "Ada", active: true }
Fix: quote every key.
{ "name": "Ada", "active": true }
If you're generating JSON from code, don't build it by string concatenation. Call JSON.stringify(value) in JavaScript or json.dumps(value) in Python, and quoting is handled for you.
4. Comments
{
"port": 8080 // default port
}
Strict JSON has no comments. Remove them, or move the note into a field such as "_comment": "default port" if your consumer ignores unknown keys. If you control the format, JSONC or JSON5 allow comments, but only tools that explicitly support those formats will accept them.
5. Invalid values: NaN, Infinity, undefined
{ "ratio": NaN, "limit": Infinity, "note": undefined }
None of these exist in JSON. Use null, a sentinel number, or a string. In JavaScript, JSON.stringify already converts NaN and Infinity to null and drops keys whose value is undefined. These usually show up when someone writes JSON by hand or uses a custom serializer.
6. Leading zeros and other number mistakes
01, +5, .5, and 5. are all invalid. JSON numbers can't have leading zeros or a leading plus sign, and need digits on both sides of a decimal point. Write 1, 5, 0.5, and 5.0. Hex such as 0xFF isn't allowed either.
A related trap that isn't a syntax error: integers larger than 2^53 (about 9 quadrillion) lose precision when JavaScript parses them. 12345678901234567890 becomes 12345678901234567000. Send large IDs as strings.
7. Raw line breaks and tabs inside strings
{ "message": "line one
line two" }
Control characters must be escaped inside strings. Fix:
{ "message": "line one\nline two" }
This often happens when you paste multi-line text into a JSON value by hand.
8. Invalid escapes
Only \", \\, \/, \b, \f, \n, \r, \t, and \uXXXX are valid escapes. Windows paths are the classic failure: "C:\new\folder" contains \n (which silently becomes a newline) and \f. Double the backslashes: "C:\\new\\folder", or use forward slashes.
9. Byte-order mark (BOM) and invisible characters
Some editors on Windows save UTF-8 files with a BOM (the bytes EF BB BF). Strict parsers reject it as an unexpected token at position 0. Python, for example, raises "Unexpected UTF-8 BOM" unless you open the file with encoding="utf-8-sig".
Toolstik trims input before parsing, so a pasted BOM is removed and the JSON may validate fine here while still failing in your app. If a file validates in the browser but fails in production, re-save it as "UTF-8" without BOM. Zero-width spaces and non-breaking spaces copied from chat apps or docs cause similar mysteries, so retype the area around the reported column.
10. Wrapped or double-encoded JSON
Sometimes the "JSON" is really a string containing JSON:
"{\"name\":\"Ada\"}"
That's valid JSON, but it's a string value, not an object. Parse it twice, or fix the producer so it doesn't call JSON.stringify on something that's already a string.
Other wrappers to look for:
- Base64. A payload starting with
eyJis very likely Base64-encoded JSON. Decode it with the Base64 Encoder / Decoder first. - Percent-encoding. JSON from a query string arrives looking like
%7B%22name%22.... Run it through the URL Encoder / Decoder with encodeURIComponent / decodeURIComponent switched on, then click Decode.
What the line and column actually mean
Most parsers, including Toolstik's, report the first character they could not accept. The mistake is often just before that point: a missing comma on the previous line, an extra comma after the last item, or a quote that never closed. If the tool says "column 1", look at the end of the previous line first.
JSON is also unforgiving about numbers: 01 and .5 are invalid. Write 1 and 0.5. Infinity, NaN, and hexadecimal literals are not JSON either, even though JavaScript accepts them.
A quick debugging routine
- Paste the JSON into the JSON Formatter and click Validate.
- If you get Invalid JSON with a line and column, go there and inspect the character just before it.
- Check the usual suspects in order: trailing comma, quotes, comments, escapes.
- Validate again. Parsers stop at the first error, so several rounds are normal.
- Once it's valid, click Format to read the structure, or Minify for transport. JSON pretty print vs minify explains when to use each.
For the full walkthrough of the tool's buttons and output, see how to format and validate JSON online. All the JSON, JWT, encoding, timestamp, and regex utilities are collected in free developer tools online.
Frequently asked questions
Tools in this guide
JSON Formatter & Validator
Format, validate, and minify JSON. Tree view with syntax error highlighting.
Base64 Encoder / Decoder
Encode or decode text to Base64 with optional URL-safe output—all in your browser.
URL Encoder / Decoder
Encode or decode URLs and query components with encodeURI or encodeURIComponent.
Keep reading
- DeveloperHow to Format and Validate JSON OnlineFormat and validate JSON online in your browser: paste, click Format, Minify, or Validate, and get line and column hints for syntax errors. No upload.
- DeveloperJSON Pretty Print vs Minify — What's the Difference?JSON pretty print vs minify: what each does, how much size you actually save, how gzip changes the math, and when to use each format in your workflow.
- DeveloperFree Developer Tools Online: JSON, JWT, Base64, URL, Timestamp & RegexFree developer tools online that run in your browser: format JSON, decode JWTs, encode Base64 and URLs, convert Unix timestamps, and test JavaScript regex.