Developer guide · 6 min read

How to Fix Common JSON Syntax Errors

A practical guide to finding the small punctuation mistakes that stop JSON from parsing.

JSON is a dependable way to exchange structured data, but its syntax is strict. A single missing quote or extra comma can make an otherwise useful payload fail to parse. This guide walks through frequent errors and a quick method for tracking them down.

1. Remove trailing commas

Standard JSON does not allow a comma after the final property or array item. JavaScript may accept trailing commas in some contexts, but JSON parsers reject them.

Incorrect: {"name":"Ari",}
Correct: {"name":"Ari"}

2. Quote every property name

Object keys in JSON must be strings enclosed by double quotes. Unquoted keys are valid in some JavaScript object literals, but are not valid JSON.

Incorrect: {name:"Ari"}
Correct: {"name":"Ari"}

3. Use double quotes for strings

JSON strings use double quotes. Replace single quotes around a value with double quotes, and escape any double quote that appears inside the string with a backslash.

4. Match brackets and braces

Each opening curly brace or square bracket needs a matching closing symbol. When the document is nested, inspect the nearest structure around the parser's reported position. Indentation can make a missing or misplaced bracket easier to spot.

5. Use JSON values, not JavaScript values

JSON supports strings, numbers, objects, arrays, true, false, and null. It does not support comments, undefined, functions, or NaN. Replace unsupported values with a representation that fits your data contract.

A quick debugging workflow

  1. Copy the exact payload that failed, without changing it first.
  2. Run it through a parser or formatter to reveal the first syntax error.
  3. Check quotes and commas near that location.
  4. Fix one issue at a time, then validate again.
  5. Once valid, format it to inspect the nesting and expected values.
Ready to check a JSON snippet? Open the free JSON Formatter →

Use the free JSON formatter

The Perkability JSON formatter validates and formats JSON in your browser. Paste a snippet and select Format JSON. Valid input becomes readable; invalid input returns an error message to help you continue debugging.