Reviewed and updated 24 July 2026

JSONFormatView guide

Common JSON Syntax Errors and How to Fix Them

Most JSON parse failures come from a small group of punctuation and escaping mistakes. This guide explains why each one fails and how to correct it without changing the intended data.

Start with the first parser error, inspect the token immediately before it, and validate again after each correction. One missing quote can cause several later messages that disappear when the first defect is fixed.

Trailing and missing commas

A comma separates members in an object and items in an array. It cannot appear after the final member or item. Conversely, two adjacent values need a comma between them. JavaScript object literals may allow a trailing comma, but standard JSON does not.

Invalid: {"name":"Ada",}. Valid: {"name":"Ada"}. If the parser points at a closing brace or bracket, inspect the preceding value for a trailing comma. If it points at a new property name, inspect for a missing comma.

Single quotes and unquoted keys

JSON strings and object member names use double quotes. A JavaScript-like value such as {name: 'Ada'} is not JSON even though it may be accepted inside source code. Write {"name":"Ada"} instead.

Changing quote characters mechanically can be unsafe when apostrophes or embedded quotes occur inside the string. Review the transformed text and escape literal double quotes as \".

Escapes and control characters

A backslash begins an escape sequence. JSON recognizes escapes such as \", \\, \n, \t, and \u followed by four hexadecimal digits. A literal line break cannot occur inside a quoted string; represent it with \n.

Windows paths require escaped backslashes—for example, "C:\\temp\\file.json". An invalid escape such as \q fails even though the surrounding quotes are balanced.

Numbers, literals, and comments

JSON numbers cannot contain a leading plus sign, NaN, Infinity, hexadecimal notation, or an unnecessary leading zero. The keywords true, false, and null are lowercase and unquoted.

Standard JSON does not allow // or /* */ comments. Remove comments or use a configuration format explicitly designed to support them. Do not silently strip comment-like text that appears inside a quoted string.

Mismatched or truncated containers

Every { needs a matching } and every [ needs a matching ]. A response cut off during transport often ends in an unterminated string or open container. In that case, obtain the complete source rather than guessing the missing data.

Indenting each level after the basic syntax is repaired makes unmatched containers easier to see. For generated JSON, fix the serializer or producer instead of repeatedly correcting its output by hand.

Frequently asked questions

Why does the error point after the real mistake?

A parser often recognizes a problem only when the next token becomes impossible. Check the preceding comma, quote, or bracket.

Can JSON contain comments?

No. Use external documentation or a comment-supporting configuration format.

Is a JavaScript object literal valid JSON?

Only if it also follows JSON’s stricter rules for quotes, keys, values, and syntax.