How to Validate JSON (and Fix Common Errors)

Invalid JSON almost always comes down to a handful of repeat offenders. Here's how to find and fix them.

By Web Tools Centre Team · Published September 12, 2026

What 'valid JSON' actually means

JSON has a strict, small grammar: object keys and string values are double-quoted, numbers have no leading zeros or trailing decimal points, and there is no trailing comma after the last item in an array or object. A single stray character breaks the whole document — unlike HTML, JSON parsers do not guess at your intent.

The most common errors

How to find the actual line

Most validators only tell you "unexpected token" and a position — paste the JSON into the JSON Formatter and use Validate; it points at the exact character, which is usually faster than scanning by eye in a deeply nested payload.

A quick workflow

Quick FAQ

Why does JSON.parse() work in one language but fail in another?

Some parsers, and JavaScript engines specifically outside strict JSON.parse, are more lenient about things like trailing commas or single quotes. Strict JSON parsers follow the spec exactly, so code that "works" in a lenient environment can still be invalid JSON.

Can JSON have comments?

No. There is no comment syntax in the JSON specification. For annotated config files, consider JSON5 or YAML, or strip comments before parsing.

Is a JSON file with a trailing newline still valid?

Yes. Whitespace outside of strings, including a trailing newline, is ignored by JSON parsers and does not affect validity.