Toollance

5 JSON Formatting Mistakes That Break Your API

jsonapidev-tools

Trailing commas

A trailing comma after the last item in an object or array is valid in JavaScript but invalid JSON:

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

Run this through a JSON formatter and the extra comma is flagged instantly.

Unquoted or single-quoted keys

JSON requires double quotes around every key and string value. Single quotes or unquoted keys are common mistakes when copying from JavaScript source code.

Duplicate keys

Duplicate keys are technically allowed by the JSON spec, but parsers resolve them inconsistently — some keep the first value, others the last. Avoid them entirely.

Mixing data types

Keeping a field’s type consistent across records (always a string, always a number) prevents downstream consumers from writing defensive type-checks everywhere.

Not validating before deploying

The cheapest fix is catching the error before it ships. Paste your payload into a formatter/validator as part of your workflow, not after a bug report.