My Tool Studio
Developer Tools·3 min read

How to Validate JSON and Fix Syntax Errors

When an app refuses to start or an API rejects a request body, the log often says only that the JSON is invalid. The JSON Validator tells you where and why. Paste the text and it checks as you type, highlighting the bad line and giving the column and a plain-English reason. It runs in your browser, so nothing is uploaded.

12345{"id": 42,"email": "a@b","role":}Missing value1 error found

What the JSON Validator checks

One question, answered clearly.

The tool first runs your browser's own JSON parser. If that succeeds, the JSON is valid and the result shows its top-level type, nesting depth and size. Because this is the same parser your front-end code uses, a pass here means JSON.parse will accept it too. The Standard menu can switch to the older RFC 4627 rule, which only accepts an object or array at the top level.

If the parse fails, the line is highlighted in the editor and a stricter reader stops at the first character that breaks the rules. You see the line and column, a short reason such as a missing comma, and the nearby lines with a caret under the problem. Go to error moves the cursor there.

Valid JSON can still hide problems, so the result also warns about duplicate keys and numbers too large for JavaScript to hold exactly, such as a 19-digit ID. JSON.parse accepts both without a word.

The mistakes behind most invalid JSON

Usually one small thing.

Most errors come from editing a file by hand or copying an object out of JavaScript or Python code. The usual suspects:

  • A comma after the last item in an object or array.
  • Single quotes around a string or key. JSON needs double quotes.
  • A property name without quotes.
  • A // or /* */ comment, which JSON does not allow.
  • Python-style True, False or None instead of true, false and null.
  • A missing comma between two items.

Fix common errors in one click

Repairs the predictable slips.

Press Fix common errors and the tool removes trailing commas, comments and a stray byte order mark, switches single quotes to double quotes, wraps bare property names in quotes, replaces True, False and None, and writes NaN, Infinity and undefined as null. A message lists each kind of fix it applied.

It does not guess missing commas or brackets, because the right fix depends on what you meant. For those, go to the reported line and correct it by hand. Parsing stops at the first error, so the next one only shows once the first is fixed. Keep going until the result says Valid JSON.

Format once it passes

Checking and tidying in one place.

When the JSON is valid, press Format to pretty-print it right in the input box, using the Format indent you pick, or Minify to pack it onto one line. That makes it easy to read a long payload and spot a value that looks wrong. For a tree view or key sorting, the JSON Formatter goes further.

Valid syntax is not the same as the right shape

Checking structure with a schema.

A common puzzle: an app rejects JSON that passes the syntax check. An endpoint might return an object where your code expects an array, or a number as a string. Syntax alone cannot catch that.

For that, tick Also validate against a JSON Schema and paste your schema. Pick a draft, from draft 4 to 2020-12, or let the tool read $schema. Each rule that fails is listed with its path in your data, such as /items/0/price. The JSON Schema Validator page adds schema generation from sample data if you do not have a schema yet.

JSON is not JavaScript

Two formats that look alike.

JSON borrows its look from JavaScript, but a JavaScript object literal with comments, single quotes or trailing commas is not valid JSON. The same goes for JSON5, a looser format some config files use. This tool checks standard JSON as defined in RFC 8259. To lint JavaScript code, use a JavaScript linter instead.

Once your JSON passes, the JSON to CSV Converter can turn an array of records into a spreadsheet, and the JSON to TypeScript tool can write interfaces from it.

Try it now

Open JSON Validator

The tool is one click away. No sign up, no upload, no payment.

Open JSON Validator