JSON validation guide

Fix Invalid JSON: Common Syntax Errors with Examples

Invalid JSON usually comes from a tiny punctuation mistake, but the parser often stops far from the cause. A disciplined check—syntax first, structure second, schema last—finds the problem faster.

Open JSON Formatter & Validator

Start with the parser error

Paste the complete document into JSON Formatter & Validator and select Validate. The tool parses locally and reports the line and column when the browser can identify them.

Treat the reported position as a starting point. A missing quote or brace on the previous line can make the next valid token look wrong.

  1. Read the first error before changing anything.
  2. Inspect the reported line and the line immediately above it.
  3. Fix one issue, then validate again so later errors are not masked.

Trailing commas and missing separators

JSON requires commas between members and forbids a comma after the final member. JavaScript object literals may tolerate syntax that JSON does not.

Before

{
  "name": "Ada",
  "active": true,
}

After

{
  "name": "Ada",
  "active": true
}

Quotes, escapes, and property names

Every object key and every string must use double quotes. Escape quotes inside strings with a backslash, and do not paste raw line breaks inside a quoted string.

Single quotes, unquoted keys, comments, NaN, Infinity, and undefined are JavaScript features, not standard JSON values.

Validate structure, then validate meaning

A document can be valid JSON and still be wrong for an API. Once syntax passes, use JSON Schema Validator when you have a schema, or Type Profiler to inspect the types that actually occur.

Pretty formatting is a review aid, not a correctness guarantee. It makes missing siblings, unexpected nesting, and array boundaries easier for people to see.

Common questions

FAQ

Can JSON contain comments?

No. Standard JSON has no comment syntax. Remove comments before parsing.

Are trailing commas valid JSON?

No. The last member of an object or array cannot end with a comma.

Does formatting change JSON values?

No. Pretty formatting changes whitespace only after the document parses successfully.