NNonkera
Developer ToolsUpdated July 31, 2026

Common JSON Syntax Errors and How to Fix Them

The JSON syntax mistakes that trip people up most often — trailing commas, single quotes, unquoted keys — explained with the exact fix for each.

Trailing commas

The single most common JSON error is a trailing comma left after the last item in an object or array — {"a": 1, "b": 2,} or [1, 2, 3,]. This is completely legal in JavaScript object and array literals, which is exactly why it's such an easy mistake to carry over into JSON, where it's strictly forbidden by the specification. The fix is always the same: delete the comma immediately before the closing } or ]. Most editors and formatters will point directly at the closing bracket when this is the problem, since that's technically where the parser first notices something is wrong.

Single quotes instead of double quotes

JSON requires double quotes for both keys and string values — {'name': 'Ada'} is invalid; it must be {"name": "Ada"}. This one trips up developers coming from JavaScript or Python, both of which accept single quotes for strings interchangeably with double quotes. JSON has no such flexibility: single quotes anywhere in a JSON document are a syntax error, no exceptions.

Unquoted or improperly quoted keys

In JavaScript, object keys can often be written without quotes at all ({name: "Ada"}), but JSON requires every key to be a double-quoted string, with no exceptions — {"name": "Ada"} is the only valid form. This is another case where JSON is deliberately stricter than the JavaScript object literal syntax it superficially resembles, precisely because JSON is meant to be a simple, unambiguous data-interchange format parseable by many different languages, not just JavaScript.

Comments

JSON has no comment syntax at all — neither // nor /* */ style comments are valid anywhere in a JSON document, which surprises people used to JSONC (JSON with Comments, used by some config files like VS Code's settings) or JS/TS source files. If you need to annotate a JSON file, the JSON specification offers no built-in way to do it; some tools support a JSONC superset specifically to work around this, but plain JSON parsers will reject any document containing a comment.

Mismatched or missing brackets and braces

An unclosed { or [ — often from a large, deeply nested document where a closing bracket got deleted or never added during editing — produces an error, but usually not at the exact spot the bracket is missing; the parser typically reports the error at the point it ran out of content to match against, which can be much later in the document than where the actual problem started. When a validator's reported error line doesn't obviously contain a mistake, checking that every {, [, ", and comma has a proper matching counterpart from that point backward toward the start of the document is usually where the real issue turns up.

Auto-format to spot structural issues

A faster way to catch these than reading line by line

All of these errors share one thing in common: they're often invisible when eyeballing dense, minified JSON, but immediately obvious once the document is properly indented, since consistent indentation visually exposes an unclosed bracket or a stray comma. Running a suspect JSON payload through a formatter first, then a validator if formatting itself fails, catches the overwhelming majority of these issues faster than manually scanning a wall of text character by character.

Frequently asked questions

Why does my JSON error point to the wrong line?

JSON parsers report errors at the point they realize something doesn't match, which for an unclosed bracket or missing comma can be well past where the actual mistake was made — check backward from the reported line, not just at it.

Are trailing commas ever allowed in JSON?

No — unlike JavaScript object and array literals, standard JSON never permits a trailing comma after the last item in an object or array.

Can I use single quotes in JSON?

No — JSON requires double quotes for all keys and string values, with no exceptions.

Does JSON support comments?

No — plain JSON has no comment syntax. Some tools support a JSONC (JSON with Comments) superset, but a standard JSON parser will reject any comment.

What's the fastest way to find a JSON syntax error?

Run the JSON through a formatter first — proper indentation makes structural issues like unclosed brackets far easier to spot visually than scanning minified text.