Common JSON Errors and How to Fix Them

By Ramanathan Aug 9, 2026 2 min read JSON Formatter & Validator

When a JSON parser fails, the message can look cryptic — "Unexpected token } in JSON at position 42." Almost always it's one of a handful of mistakes. Here's what each error means and how to fix it.

"Unexpected token ... in JSON at position N"

This is the catch-all parse error. The position (or line/column) is where the parser gave up — but the real mistake is often just before it. Common causes:

  • A missing comma between two items.
  • An extra comma after the last item (see trailing commas below).
  • A missing closing } or ].

Fix: format the JSON so the structure is visible, then look at the reported line and the line above it.

Single quotes instead of double

{ 'name': 'Ada' }

JSON requires double quotes for both keys and string values. Replace every ' with ":

{ "name": "Ada" }

Trailing commas

{ "a": 1, "b": 2, }

The comma after 2 is invalid in JSON. Remove the last comma in every object and array:

{ "a": 1, "b": 2 }

Unquoted keys

{ name: "Ada" }

Keys copied from JavaScript often lose their quotes. Every key must be a quoted string:

{ "name": "Ada" }

Invalid values: NaN, undefined, comments

{ "score": NaN, "note": undefined }

JSON has no NaN, Infinity, undefined, functions, or comments. Use null for missing values and a valid number for score, and delete any // or /* */ comments.

Unescaped characters in a string

A raw newline or an unescaped " inside a string breaks it. Escape them with a backslash: \n, \", \\.

A hidden BOM or trailing content

If JSON looks perfect but still won't parse, check for a byte-order mark at the very start of the file, or extra characters after the final }. Both are invisible in most editors but fatal to a parser.

The fastest way to find the mistake

Reading position offsets by eye is slow. Paste the JSON into a formatter — it highlights the exact line and column of the first error, so you fix the cause instead of hunting for it. For the validation pattern in code, see How to Validate JSON in JavaScript, and for the rules behind these errors, JSON Syntax Rules Explained.

Try it

Paste your broken JSON — the exact line and column of the problem is flagged instantly, right in your browser.

About the author

Ramanathan · Software Engineer & Solutions Architect

I'm a Software Engineer and Solutions Architect with 20+ years of experience building enterprise applications across BFSI, Healthcare, Retail, Manufacturing, and Industrial Automation. I've spent those two decades living in JSON, tokens, regexes, and config files — so I built the fast, private, no-login developer tools I always wanted to reach for myself.

Last updated: Aug 9, 2026