DevToolsmith

JSON Validator

Paste JSON to check whether it is valid. Errors are shown with their exact line and column and a plain-English explanation, and the most common mistakes can be fixed with one click.

Runs 100% in your browser — nothing is uploaded

JSON input
Line 2, column 3: Property names must be double-quoted strings110 chars · 110 bytes · 6 lines
Formatted JSON
0 chars · 0 bytes · 0 lines

The most common JSON errors

These six cause nearly every “invalid JSON” error. The message under each one is exactly what the validator reports, and the fix is what the Repair button produces.

Trailing comma

JavaScript allows a comma after the last item; JSON does not.

Invalid
{
  "name": "Ada",
  "admin": true,
}

Line 4, column 1: Trailing comma before } is not allowed

Fixed
{
  "name": "Ada",
  "admin": true
}

Single quotes

Strings and keys must use double quotes.

Invalid
{
  'name': 'Ada'
}

Line 2, column 3: Property names must be double-quoted strings

Fixed
{
  "name": "Ada"
}

Unquoted key

Every key must be a double-quoted string, even simple ones.

Invalid
{
  name: "Ada"
}

Line 2, column 3: Property names must be double-quoted strings

Fixed
{
  "name": "Ada"
}

Comments

JSON has no comment syntax. Use JSONC or JSON5 files for configs that need comments.

Invalid
{
  // the user name
  "name": "Ada"
}

Line 2, column 3: Property names must be double-quoted strings

Fixed
{
  "name": "Ada"
}

Missing comma

Usually caused by adding a line without a comma on the line above.

Invalid
{
  "name": "Ada"
  "admin": true
}

Line 3, column 3: Expected ',' or '}' after property value, found '"'

Fixed
{
  "name": "Ada",
  "admin": true
}

Python values

Python’s print() output isn’t JSON. Use json.dumps() instead.

Invalid
{
  "admin": True,
  "manager": None
}

Line 2, column 12: Unexpected 'T': expected a value

Fixed
{
  "admin": true,
  "manager": null
}

Other things that are not valid JSON

  • undefined, NaN and Infinity. Use null or a string.
  • Numbers with leading zeros (007), a leading +, or hex like 0xFF.
  • Raw line breaks or tabs inside strings. They must be written as \n and \t.
  • Escapes other than \" \\ \/ \b \f \n \r \t \uXXXX. \' and \x41 are invalid.

Valid doesn’t always mean safe to parse. Repeated keys and numbers like 9007199254740993 or 1e400 are legal JSON, but JavaScript’s JSON.parse drops or changes them. The validator warns about both; see exactly what changes.

Validate JSON in code

JavaScript
function isValidJson(text) {
  try {
    JSON.parse(text);
    return true;
  } catch {
    return false;
  }
}
Python
import json

try:
    json.loads(text)
except json.JSONDecodeError as e:
    print(f"line {e.lineno}, column {e.colno}: {e.msg}")
Shell
jq empty data.json && echo valid

Validating YAML instead? Use the YAML validator. Once your JSON is valid, the JSON formatter can pretty-print or sort it.

Frequently asked questions

How do I check if JSON is valid?

Paste it into the validator above. A green bar means it is valid JSON; otherwise you get the exact line and column of the first error with an explanation. From code, call JSON.parse in JavaScript or json.loads in Python inside a try block, or run jq . file.json on the command line.

What does “Unexpected token” mean in JSON.parse?

The parser found a character it did not expect at that position, such as a single quote, a trailing comma, a comment or an HTML page returned instead of JSON. “Unexpected token < in JSON at position 0” almost always means the server sent an HTML error page; check the response status and Content-Type.

Are comments allowed in JSON?

No. The JSON spec (RFC 8259) has no comments. Some tools accept “JSON with comments” (JSONC), like VS Code’s settings.json and tsconfig.json, but strict parsers reject them. The Repair button removes comments.

Are duplicate keys valid JSON?

RFC 8259 says keys “SHOULD be unique” but does not forbid duplicates, so most parsers accept them and silently keep the last value. That makes them a common source of bugs; the validator warns when it finds any.

Does it validate against a JSON Schema?

No, this checks syntax only: whether the text is well-formed JSON. Schema validation checks that the data has the right fields and types, which needs the schema itself and a library such as Ajv in JavaScript or jsonschema in Python.