Dev Studio Open tools

Common JSON syntax errors and how to fix them

By Nexo Design · Published 22 November 2026 · 4 min read

JSON parsers stop at the first mistake they find, and their messages are often terse. This page lists the errors that cause most failures, with a broken example, the corrected version, and the message Dev Studio's JSON Viewer shows for each one.

Press Check in JSON Viewer on any broken example to see the error highlighted, then fix it yourself.

1. Trailing commas

A comma after the last item in an object or array is allowed in modern JavaScript but not in JSON. It often appears after deleting the final line of a list.

{
  "name": "Ada",
  "role": "admin",
}
{
  "name": "Ada",
  "role": "admin"
}

Dev Studio says: Trailing comma before } (or ] for arrays).

2. Single quotes

JSON strings and keys must use double quotes. Single quotes usually sneak in when JSON is typed by hand or copied from Python or JavaScript code.

{'name': 'Ada'}
{"name": "Ada"}

Dev Studio says: Keys need double quotes, or Strings need double quotes when only the value is wrong.

3. Unquoted keys

In a JavaScript object literal you can write {name: "Ada"}. In JSON every key must be a quoted string.

{name: "Ada", age: 36}
{"name": "Ada", "age": 36}

Dev Studio says: Expected a quoted key but found "n".

4. Comments

JSON has no comment syntax. If you need to document a configuration file, keep the notes in a README, add a field such as "_note" that your program ignores, or use a format designed for comments, such as JSONC (used by some editors) or YAML.

{
  // retry up to three times
  "retries": 3
}
{
  "_note": "retry up to three times",
  "retries": 3
}

Dev Studio says: Comments aren't allowed in JSON.

5. Missing commas

Every item except the last needs a comma after it. This error often happens when two lines are pasted together.

{
  "name": "Ada"
  "role": "admin"
}

Dev Studio says: Expected , or } but found a double quote. The error points at the start of the line after the missing comma, so look one line up.

6. Mismatched or missing brackets

Every { needs a matching }, and every [ a matching ]. Mixing them up, or losing one at the end of a long file, is common.

{"tags": ["red", "blue"}
{"tags": ["red", "blue"]}

Dev Studio says: Expected , or ] but found "}". If the closing bracket is missing entirely, you'll see … but found end of input. Formatting the document with indentation makes the mismatch easy to spot.

7. Line breaks and quotes inside strings

A string can't contain a raw line break or an unescaped double quote. Use \n for a new line and \" for a quote.

{"message": "She said "hi"
and left"}
{"message": "She said \"hi\"\nand left"}

Dev Studio says: Expected , or } but found "h" for the stray quote, or Unterminated string for the line break.

8. Numbers that aren't JSON numbers

JSON numbers are stricter than most programming languages:

  • No leading zeros: 007 must be 7, or the string "007" if the zeros matter (as in a postcode or product code).
  • No NaN, Infinity or -Infinity. Use null or leave the field out.
  • No leading +, and no bare decimal point such as .5 or 5..
{"code": 007, "ratio": NaN, "delta": +1}
{"code": "007", "ratio": null, "delta": 1}

Dev Studio says: Numbers can't have leading zeros, NaN and Infinity aren't valid in JSON or Numbers can't start with +.

9. Values from other languages

Python writes True, False and None; JavaScript has undefined. None of them are valid in JSON. Use lowercase true, false and null.

{"active": True, "manager": None}
{"active": true, "manager": null}

Dev Studio says: JSON uses lowercase true, false and null, or undefined isn't valid in JSON; use null.

The underlying fix is to stop building JSON by hand: in Python, use json.dumps(); in JavaScript, use JSON.stringify(). Both always produce valid output.

10. Curly "smart" quotes

Word processors, chat apps and some websites replace straight quotes with curly ones (“ ” ‘ ’). They look almost identical but are different characters, and JSON only accepts the straight double quote ".

{“name”: “Ada”}

Dev Studio says: Curly quotes aren't valid; use straight double quotes ("). Copy JSON from a code editor or plain-text source rather than from a document, or use your editor's find-and-replace to swap the characters.

A checklist when JSON won't parse

  1. Read the line and column in the error, then check the line above as well.
  2. Format the document so the nesting is visible.
  3. Search for ', //, ,} and ,].
  4. Look for words like True, None, NaN and undefined.
  5. If the JSON came from a document or chat message, check for curly quotes.