Developers · 30 October 2026

Seven JSON Mistakes That Break Your API Calls

Trailing commas, single quotes and other small errors that cause big headaches, and how to find them fast.

JSON looks like JavaScript, which is exactly why people get it wrong. It is stricter than it appears. Here are the slips that cause most of the "Unexpected token" errors.

  1. Trailing commas. {"a": 1,} is valid in JavaScript and invalid in JSON.
  2. Single quotes. Keys and strings must use double quotes.
  3. Unquoted keys. {name: "Asha"} works in code, not in JSON.
  4. Comments. JSON has none. Remove them or use a separate field.
  5. Special values. undefined, NaN and Infinity do not exist in JSON. Use null or a string.
  6. Line breaks inside strings. Use \n instead of a real new line.
  7. Wrong escaping. Backslashes and quotes inside strings need escaping.

Finding the problem quickly

Paste your JSON into the JSON Validator. It tells you whether it is valid and, if not, gives the reason the parser stopped. Then use the JSON Formatter to indent it, so the structure is easy to read and the missing bracket is obvious.

Before you ship

Once the data is correct, the JSON Minifier removes spaces and line breaks. That makes API responses smaller and faster. Keep the readable version in your repository, and minify only what goes over the wire.

A final habit: when an API call fails, look at what you actually sent, not what you meant to send. Printing the request body and pasting it into a validator solves more bugs than staring at your code.

Tools mentioned in this article