How to Fix Common JSON Errors (Trailing Commas, Quotes & Brackets)
June 18, 2026
Almost every JSON error comes down to one of a handful of mistakes: a stray comma, a missing quote, an unclosed bracket, or a value that isn't valid JSON in the first place. This guide walks through each one, shows the exact error message you'll usually see, and explains how to fix it fast.
Why JSON is so strict
JSON (JavaScript Object Notation) looks forgiving, but the spec is deliberately narrow so that every parser on every platform agrees on what a document means. There are no comments, no trailing commas, and strings must use double quotes. Once you know the rules, the errors become predictable.
1. Trailing commas
The single most common JSON error. A comma after the last item in an object or array is valid in JavaScript but not in JSON.
// ❌ Invalid – trailing comma after "blue"
{
"colors": ["red", "blue",]
}
// ✅ Valid
{
"colors": ["red", "blue"]
}Typical message: Unexpected token ] in JSON or Trailing comma. Remove the comma before the closing ] or }.
2. Single quotes instead of double quotes
JSON requires double quotes for both keys and string values. Single quotes are a JavaScript habit that JSON rejects.
// ❌ Invalid
{ 'name': 'Ada' }
// ✅ Valid
{ "name": "Ada" }Typical message: Unexpected token ' in JSON at position 0.
3. Unquoted keys
Object keys must always be quoted strings. Bare identifiers are valid JavaScript object literals but not JSON.
// ❌ Invalid
{ name: "Ada" }
// ✅ Valid
{ "name": "Ada" }4. Missing or mismatched brackets
Every { needs a matching } and every [ a matching ]. When they don't balance, the parser usually reports an error at the very end of the document — "Unexpected end of JSON input" — even though the real mistake is earlier. Formatting the document with indentation makes the imbalance visible at a glance.
5. Comments
JSON has no comment syntax. // ... and /* ... */ both cause errors. If you need comments (for config files), use a superset like JSON5 or strip them before parsing.
6. Wrong value types
Values may be a string, number, true, false, null, object, or array — nothing else. Common slip-ups:
undefinedis not valid JSON — usenull.- Numbers can't have leading zeros or a trailing dot (
01,5.). - Dates aren't a JSON type — store them as ISO strings (
"2026-06-18"). NaNandInfinityare not allowed.
7. Unescaped characters in strings
Double quotes, backslashes, and control characters inside a string must be escaped.
// ❌ Invalid – unescaped quote
{ "quote": "She said "hi"" }
// ✅ Valid
{ "quote": "She said \"hi\"" }The fastest way to find the error
Reading a long single-line JSON blob by eye is painful. Paste it into the JSON Formatter & Validator — it pinpoints the line and character of the first error, highlights the syntax, and beautifies the document so mismatched brackets and stray commas jump out. Everything runs in your browser, so your data never leaves your device.
Quick checklist
- No trailing commas.
- Double quotes on every key and string.
- Brackets and braces balanced.
- No comments.
- Only valid value types;
nullinstead ofundefined. - Escape
"and\\inside strings.