How-to · December 5, 2026

Seven common JSON errors and how to fix them (use the formatter to find the line)

JSON looks like JavaScript but is much stricter, and a single stray character makes a parser refuse the whole document. These are the seven mistakes people make most often, with a wrong and a corrected version of each. Paste your text into the JSON formatter on this site to see where parsing stops. It runs in your browser and does not upload anything.

1. Trailing comma

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

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

2. Single quotes

Wrong:   {'name': 'Ana'}
Correct: {"name": "Ana"}

Strings and keys must use double quotes.

3. Unquoted keys

Wrong:   {name: "Ana"}
Correct: {"name": "Ana"}

4. Comments

Wrong:   {"a": 1 // first value
}
Correct: {"a": 1}

Standard JSON has no comments. Remove them, or use a separate field if you need notes.

5. Unescaped quotes or line breaks in strings

Wrong:   {"quote": "She said "hi""}
Correct: {"quote": "She said \"hi\""}

Inside a string, a double quote needs a backslash, and a line break must be written as \n.

6. Values that are not valid JSON

Wrong:   {"a": undefined, "b": NaN}
Correct: {"a": null}

JSON has strings, numbers, true, false, null, objects and arrays. Values like undefined or NaN are not part of it.

7. Missing or extra brackets

Every opening brace or bracket needs a closing one. If a formatter reports an error at the very end of the text, a closing bracket is often missing earlier. Format the text and look at the indentation: a block that is indented where it should not be points to the problem.

How to debug quickly

  1. Paste the text into the formatter and read the error message, which usually gives a position.
  2. Fix the first error only, then try again, because later errors may disappear.
  3. If the text came from an API, save the raw response before changing it.

A privacy note

JSON often contains tokens, emails or personal data. Because the formatter on this site runs in your browser, nothing is sent to a server, but you should still remove secrets before sharing a snippet with anyone.

Frequently asked questions

Is JSON the same as a JavaScript object?

No. JSON is a text format with strict rules, and JavaScript objects allow things JSON does not, such as comments in code, single quotes and unquoted keys.

Can JSON have comments?

Not in the standard. Some tools accept them as an extension, but a strict parser will reject them.

Where is the official definition?

In RFC 8259, linked below.

Related on this site

Sources

← All posts on Edge Tools micro-tools

Header photo: Wrench Sockets by Jaroslaw%20Puszczy%u0144ski, CC0 1.0 (cropped and resized)