JSON validator and formatter

Validate, format or minify JSON instantly in your browser.

About the JSON validator

The BapTools JSON validator finds syntax errors with their line numbers and also formats or minifies JSON so it is easier to read and to send. Everything happens locally in your browser.

How is JSON different from XML?

  • Double quotes are mandatory: both keys and string values need ".
  • No trailing commas: JSON rejects a comma at the end of an object or array.
  • No comments: a // or /* */ line is treated as an error.
  • Simple values only: no NaN, Infinity or trailing decimal points.

When is this useful?

When an API call fails with Unexpected token, when you prepare a webhook payload, or when you want to diff a JSON structure before and after a change.

Real-world examples

Example 1 — single quotes instead of double

{'ten': 'Bap'} is invalid JSON because JSON only accepts double quotes. This is the single most common mistake when copying from another language.

Example 2 — a trailing comma

{"a":1, "b":2,} is rejected. JavaScript tolerates it so your code runs, but the API's JSON.parse will not.

Example 3 — comments inside JSON

A // note or /* ... */ line is reported as an error. JSON has no comment concept, so strip them before sending.

Example 4 — slimming a payload

A 40 KB response drops to about 12 KB once minified, which is much easier to paste into an issue or to send through an API with a size limit.

When to use it, and when not to

Worth using

  • Before posting a payload to an API, so a stray comma does not cost you the request.
  • Reading an API error response without knowing where it broke.
  • Reformatting a config file that was flattened onto one line.
  • Compacting data before pasting it into a bug report or group chat.

Not worth it

  • Checking that JSON matches a schema. This checks syntax, not field types or required keys.
  • Searching very large JSON files, where jq or DevTools is far quicker.
  • Converting to other formats such as YAML or CSV.

How to use it

  1. Paste your JSON into the input area.
  2. Press Validate to check for syntax errors.
  3. Press Format to pretty-print or Minify to compact it.
  4. Press Copy result to copy the output.

Frequently asked questions

What does "Unexpected token" mean?

Usually a missing double quote, a trailing comma, or single quotes used instead of double quotes. Check any special characters inside your strings.

Can I load a .json file?

Yes. Open the .json file in a text editor, copy the whole content and paste it here.

Is my JSON stored anywhere?

No. Processing happens entirely in your browser and your content is never uploaded.