JSON Viewer

The 12 most common JSON errors, and how to fix each one

Every JSON error message you are likely to meet, what it really means, and the fix.

Updated 2026-11-04 · 8 minute read

A JSON parser stops at the first fault and gives you a line and a column. The message is often unhelpful. This page lists the faults people really meet, in the order of how often they happen, with the fix for each one.

If you want the quick way: paste the document into the viewer and press Fix. It repairs most of these and tells you what it changed. But it is worth knowing what went wrong, so the next file is right the first time.

1. A trailing comma

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

The message: Unexpected token } or Expected double-quoted property name.

Why: A comma separates two items. After the last item there is nothing to separate.

The fix: Remove the comma. This is the most common fault by a wide margin, because JavaScript, Python and most other languages allow it.

2. Single quotation marks

{'name': 'Ada'}

The message: Unexpected token '.

The fix: Use double quotation marks. JSON allows no other kind. This often comes from a Python program that printed a dictionary with print() instead of writing it with json.dumps().

3. A key with no quotation marks

{name: "Ada"}

The fix: {"name": "Ada"}. The form with no quotation marks is JavaScript, and a JavaScript object is not a JSON document.

4. Python words

{"ok": True, "value": None}

The fix: true and null, in lower case. False becomes false. This means a Python program used str(data) where it needed json.dumps(data).

5. NaN or Infinity

{"ratio": NaN, "limit": Infinity}

Why: JSON has no way to write these. A division by zero made the value, and the writer put it in the file.

The fix: null, almost always. In Python, json.dumps(data, allow_nan=False) makes the program fail where the fault is, instead of writing a file nobody can read.

6. A quotation mark inside text

{"says": "She said "no" and left"}

The fix: Escape it: "She said \"no\" and left". The same goes for a backslash: a Windows path must be written "C:\\Users\\ada".

7. A real new line inside text

{"note": "first line
second line"}

The message: Unterminated string or Bad control character.

The fix: Write \n instead of pressing Enter: "first line\nsecond line".

8. A comment

{
  // the port the service uses
  "port": 8080
}

The fix: Remove it, or keep it and accept that the file is JSONC, not JSON. This viewer reads comments and keeps them when it formats, which no other common web viewer does. The full story is on the comments page.

9. The file was cut short

{"users": [{"id": 1}, {"id": 2

The message: Unexpected end of JSON input.

Why: A download stopped, a disk filled up, or a program wrote the file without closing it.

The fix: Get the file again. If you cannot, press Fix in the viewer: it closes the open brackets so you can read the part that did arrive. Know that the end of the data is still missing.

10. A byte-order mark, or other invisible text

A file that looks correct but fails at line 1, column 1 almost always starts with a byte-order mark: three bytes that some Windows programs write at the start of a file. Your editor hides it.

The fix: Save the file as "UTF-8" and not "UTF-8 with BOM". The Fix action also removes it.

A second form of this fault: a server answers with )]}', before the JSON. That is a guard against an old browser attack, and the program that reads it is meant to cut it off. Fix removes it too.

11. Two documents in one file

{"id": 1}
{"id": 2}

The message: Unexpected non-whitespace character after JSON.

Why: This is not a broken JSON file. It is a JSON Lines file, which holds one document on each line. Logs and data exports use this form.

The fix: Nothing to fix. This viewer sees it and shows the lines as a list.

12. The answer is not JSON at all

You expect JSON and you get:

<!DOCTYPE html>
<html><head><title>502 Bad Gateway</title>

Why: The server failed and sent an error page, or a proxy or a login page answered in its place.

The fix: Look at the status code and at the Content-Type header, not only at the body. A program that reads the body before it checks the status code will keep meeting this.

How to find the fault fast

  1. Trust the line number, not the message. The message says what the parser wanted, which is often not what is wrong. The place is right.
  2. Look at the line before. A missing comma shows up on the next line.
  3. Format the file first. A fault hides easily in one long line, and stands out in a formatted file.
  4. Cut the file in half. If the fault is not obvious, delete half the document and try again. Two or three cuts find it in a file of any size.

Stop the problem at the source

Most of these faults come from one habit: building JSON by joining pieces of text together.

# Do not do this
body = '{"name": "' + name + '"}'

If name holds a quotation mark, the file breaks. If it holds a backslash, the file breaks. Use the library in your language:

import json
body = json.dumps({"name": name})

Every language has one, and it handles every escape rule for you.

Try it on your own file. The tool runs in your browser. Nothing is uploaded, and nothing is stored on a server.

Open the JSON Viewer

Read next

Can JSON have comments? JSON, JSONC and JSON5

Why the JSON standard has no comments, what people do instead, and how JSONC and JSON5 differ.

JSONPath in five minutes

Find anything in a JSON document with a short expression. Every operator, with examples you can run.