← All JSON guides

JSON guide · 7 min read

How to Fix Invalid JSON: Common Errors and Examples

Find and fix invalid JSON caused by trailing commas, missing quotes, malformed values and incomplete objects.

Published 2026-08-05Reviewed 2026-08-05

What makes JSON invalid?

JSON follows a strict grammar. Property names must use double quotes, strings must be properly escaped, values must use supported JSON types and objects or arrays must close correctly.

A document can look similar to a JavaScript object and still be invalid JSON. Comments, single-quoted strings, undefined values and trailing commas are common examples.

1. Remove trailing commas

JSON does not allow a comma after the final property in an object or the final item in an array.

Invalid:
{
  "name": "JSON Hearth",
  "active": true,
}

Valid:
{
  "name": "JSON Hearth",
  "active": true
}

2. Use double quotes

Property names and string values must be enclosed in double quotes. Single quotes are accepted by JavaScript in some contexts but not by the JSON standard.

Invalid: {'name': 'Ada'}
Valid:   {"name": "Ada"}

3. Check missing commas, brackets and braces

Adjacent properties require commas, and every opening brace or bracket needs a matching closing character. Deeply nested payloads make these mistakes difficult to spot manually.

  • Add commas between object properties and array elements.
  • Match every { with } and every [ with ].
  • Validate the smallest failing section when the payload is large.

4. Replace unsupported values

Valid JSON values are strings, numbers, objects, arrays, true, false and null. Values such as undefined, NaN, Infinity, functions and dates written as language objects are not valid JSON.

A reliable repair workflow

Start with the JSON Syntax Validator to locate the parse failure. For common formatting mistakes, try Fix Broken JSON, then review the repaired output before using it in an application. Finally, format the result to make its structure easier to inspect.

Common questions

Frequently asked questions

Can invalid JSON be repaired automatically?

Many common mistakes can be repaired automatically, but ambiguous input still requires human review because a repair tool cannot always know the intended structure.

Why is my JavaScript object not valid JSON?

JavaScript object syntax permits features JSON does not, including single quotes, comments, undefined values, methods and unquoted property names.