Skip to content
Data & Developer Guides

JSON Errors Explained: The 7 Most Common Mistakes and How to Fix Them

FreeToolConvert Editorial Team Published 3 min read
In this article
  1. How to find a JSON error in seconds
  2. The 7 most common JSON errors
  3. Formatting, minifying and sorting
  4. A note on large numbers
  5. Related tools

“Unexpected token” is one of the least helpful error messages in programming. When an API rejects your request body or an app won’t load its config file, the cause is almost always one of a handful of small JSON mistakes. This guide covers the most common JSON errors, how to spot each one, and how to fix them quickly with the free JSON formatter and validator, which reports the exact line and column of the problem.

How to find a JSON error in seconds

  1. Paste your JSON into the JSON formatter, or open a .json file.
  2. Select Validate or Format.
  3. If the JSON is invalid, you get a message such as Invalid JSON at line 4, column 3: unexpected "}" (trailing commas are not allowed).
  4. Fix that spot and validate again until you see ✓ Valid JSON.

Everything runs in your browser, so it is safe to paste configuration files and API responses.

The 7 most common JSON errors

1. Trailing commas

{ "name": "Priya", "city": "Delhi", }

JavaScript allows a comma after the last item; JSON does not. Remove the comma before } or ]. The validator points out trailing commas specifically.

2. Single quotes

{ 'name': 'Priya' }

JSON strings and keys must use double quotes. Replace every ' around keys and values with ".

3. Unquoted keys

{ name: "Priya" }

Valid in JavaScript, invalid in JSON. Every key needs double quotes: "name".

4. Comments

{
  // database settings
  "host": "localhost"
}

Standard JSON has no comments. Some tools accept a variant called JSONC (used by VS Code settings, for example), but APIs and most parsers do not. Remove the comments, or move the note into a field such as "_comment".

5. Missing commas between items

{ "name": "Priya" "city": "Delhi" }

Easy to miss after editing a file by hand. The error points at the start of the second item.

6. Unescaped characters inside strings

A double quote inside a string must be written as \", a backslash as \\, and a line break as \n. Windows paths are a frequent cause: "C:\Users\priya" should be "C:\\Users\\priya".

7. Values that aren’t valid JSON

undefined, NaN, Infinity and dates like new Date() are JavaScript, not JSON. Use null, a number, or a date string such as "2026-10-05" instead.

Formatting, minifying and sorting

  • Format indents the JSON with 2 spaces, 4 spaces or tabs so the structure is easy to read.
  • Minify removes all whitespace for the smallest size, and shows how much was saved.
  • Sort keys A–Z gives a stable order, which makes two versions of a file much easier to compare in a code review or diff.

A note on large numbers

JavaScript can only represent whole numbers exactly up to 9,007,199,254,740,991. Longer IDs — some database keys, social media post IDs, 19-digit account numbers — may be rounded when formatted in any browser-based tool. If your JSON contains such numbers, keep them as strings ("id": "12345678901234567890").

For background on the format itself, read JSON formatting explained.

More guides