Why Your JSON Is Invalid: The 9 Most Common Syntax Errors
Trailing commas, unquoted keys, smart quotes and friends: the nine JSON syntax mistakes that break parsers, with instant fixes and a validation shortcut.
Two JSON parsers meeting a broken document always agree on one thing: stop at the first bad byte. Knowing the usual suspects turns an opaque error into a 10-second fix.
1. Trailing commas
JavaScript object literals tolerate [1,2,3,]; JSON forbids it. Remove the comma before a closing bracket — the number one error, and the first thing to check when a config file works locally but fails in deploy.
2. Unquoted or single-quoted keys
JSON requires {"name": 1} — keys are strings with double quotes. Single quotes and bare keys come from pasting JavaScript or Python literals. Convert the source with the JSON Formatter after fixing quotes.
3-5. Quote and escape issues
- Smart quotes: copy-paste from editors or chat apps swaps " for curly quotes that break parsing instantly.
- Unescaped inner quotes: nested double quotes need \" escaping.
- Raw control characters: real line breaks inside strings are illegal — use \n.
6-7. Comments and NaN
JSON has no comments — // or /* */ make the document invalid by spec, even when the language you copied from allows them. Likewise NaN, Infinity and undefined are not JSON values.
8-9. Structural slips
- Missing colon or comma between members — often after edits.
- Mismatched brackets, which long files make easy; the JSON Validator reports the exact line and column with an excerpt.
The 10-second workflow
Paste the document into the validator, fix the reported position, reformat with the formatter to see structure clearly, and only then minify with the minifier if the file ships to production. That order catches the remaining subtle errors too.
Related guides
JSON vs YAML vs XML: Choosing the Right Config Format
JSON, YAML and XML compared for configuration and data exchange: readability, schema support, editor safety and where each format still wins today.
Read guide →2026-09-28Text Diff Explained: How Line Diffing Works and When to Trust It
From LCS to character highlighting: how diff tools align two texts, what ignore-options actually compare, and a workflow for reviewing changes without git.
Read guide →2026-09-25Minifying JSON and CSS Safely: What Must Never Be Removed
What minifiers are allowed to touch: whitespace rules in JSON, strings and url() in CSS, real-world savings numbers and a pre-flight validation checklist.
Read guide →Try these tools
JSON Validator
Validate JSON instantly and get the exact line, column and nearby snippet of any syntax error. Valid input shows structure stats: root type, keys, depth and size.
Open tool →JSON Formatter
Pretty-print JSON with 2/4-space or tab indentation, optional key sorting, and precise error positions when the JSON is broken. Private, instant, browser-only.
Open tool →JSON Minifier
Minify JSON to a single line by stripping all insignificant whitespace. See original vs minified size and exactly how many bytes you saved. Fully offline.
Open tool →