Skip to content
JSON Tidy

JSON validator

Paste JSON to check it. Errors are listed next to it by line number. It’s checked in your browser, so nothing is uploaded.

Report

The report shows up here as you type.

Repeated keys and large numbers

This is valid JSON, and the report still shows two amber rows for it:

{
  "run_id": 9007199254740993,
  "room": "kitchen",
  "room": "lobby"
}
  • A property name used twice. JavaScript and Python both keep the last one, so room is "lobby" and "kitchen" is dropped without a warning. It usually comes from a copy and paste or from merging two objects by hand.
  • A whole number too large for JavaScript. JSON.parse reads 9007199254740993 as 9007199254740992, because JavaScript numbers are exact only up to 9007199254740991. Python reads the same text correctly, so two programs end up with different IDs. Send IDs like this as strings.

What makes JSON valid

These are the rules that get broken most, usually because JavaScript or Python allows what JSON doesn’t:

  • Property names and strings go in double quotes. Single quotes and bare names aren’t allowed.
  • No comma after the last item in an object or a list.
  • No comments. Files like tsconfig.json that have them are JSONC, which JSONC to JSON converts.
  • true, false and null are lowercase. undefined, NaN and Infinity aren’t JSON values.
  • Numbers are plain decimals: no leading zeros, no plus sign, no hexadecimal.
  • A line break or tab inside a string is written as \n or \t.
  • One value per document. A file with one object per line is JSON Lines, which JSONL to JSON reads.

The JSON format guide has an example of each. If you have an error message from your own code, paste it into the JSON error lookup.

Validating JSON in code

To check a file from a script or before a commit, parse it and see whether that failed:

// JavaScript
try {
  JSON.parse(text);
} catch (error) {
  console.error(error.message);
}

# Python, from a terminal
python3 -m json.tool data.json > /dev/null

# jq
jq empty data.json

The two commands print nothing and exit with 0 when the file is valid. Otherwise they print the line and column of the first error and exit with a non-zero code, so they work as a CI check. All three stop at the first mistake they reach.

The red message under the editor on this page comes from your browser’s JSON.parse, so in Chrome it’s the same text Node.js would throw. The rows in the report are this page’s own wording.

Checking fields and types

A syntax check doesn’t know which fields your API expects. If run_id is missing, or arrives as "48213" in quotes, the JSON is still valid. To catch that, describe the shape in a JSON Schema and run the data through the JSON Schema validator.