Developer

JSON Basics: Formatting, Validation and Common Errors

Updated 26 October 2026 · 7 min read

What valid JSON looks like, the five mistakes that break APIs, how to read parser errors, and a clean workflow to validate, format and minify payloads.

What JSON is

JSON (JavaScript Object Notation) is a plain-text format for structured data. Almost every web API, configuration file and mobile app uses it to exchange data. It looks like JavaScript, but the rules are much stricter — and that is where most errors come from.

Valid JSON is built from six value types: objects in curly braces { }, arrays in square brackets [ ], strings in double quotes, numbers, true/false, and null. Object keys must always be strings in double quotes.

The most common errors

Almost every invalid JSON document has one of these:

  • Trailing commas after the last item
  • Single quotes instead of double quotes
  • Unquoted keys
  • Comments (JSON does not allow them)
  • Unescaped line breaks inside strings

How to read a parser error

Validators report errors as a position, for example “Unexpected token } at line 12, column 5”. The real mistake is often just before that position. An “unexpected }” usually means a trailing comma on the previous line; “unexpected end of input” means a missing closing bracket or quote somewhere earlier.

Formatting the document first makes errors much easier to find, because each key sits on its own line and mismatched brackets become obvious from the indentation.

Data-type traps

Some problems are valid JSON but still break an API:

  • Numbers sent as strings ("42" instead of 42) — strict APIs reject the wrong type.
  • Very large integers such as 64-bit IDs — JavaScript loses precision above 9,007,199,254,740,991, so APIs often send them as strings.
  • Dates — JSON has no date type; the common convention is an ISO 8601 string such as "2026-10-26T10:30:00Z".
  • Duplicate keys — the JSON standard does not forbid them, but different parsers keep different values.

Format for humans, minify for machines

Pretty-printed JSON is easier to review and diff. Minified JSON is smaller to send. The API-Ready JSON workflow does both: validate → format → clean → minify.

In version control, keep configuration files formatted with consistent indentation (2 spaces is the most common) so that changes show up as small, readable diffs.

Keep secrets out of JSON you share

API responses and config files often contain tokens, passwords or personal data. Before pasting JSON into a ticket, chat or online tool, remove or mask those values. SolveIt's JSON tools run in your browser, so the data you paste is not sent to a server.

Ready to try it?Run API-Ready JSON

More from the blog