Result
Paste JSON or press Try sample. The result shows here.
How to use
Add the JSON
Paste into the JSON to check box, drop or upload a .json file, or use Load URL. Try sample loads a broken example with a single-quoted string, a trailing comma and an unquoted key.
Read the result
Validation runs as you type. Invalid JSON highlights the line and shows the column, a reason and the nearby lines with a caret. Valid JSON shows its type, depth, size and any warnings.
Fix, format or check a schema
Press Go to error or Fix common errors, then Format or Minify. To check fields and types, tick Also validate against a JSON Schema and paste your schema.
Why JSON Validator
- Highlights the error line in the editor and explains the problem, with a button that jumps to it.
- Fix common errors repairs trailing commas, single quotes, unquoted keys, comments, Python literals, NaN and a stray BOM.
- Warns about duplicate keys and numbers that lose precision, which JSON.parse accepts silently.
- An optional JSON Schema check (draft 4 to 2020-12) runs in the same page, in your browser.
Common JSON errors and how to fix them
Most invalid JSON comes from a short list of mistakes, usually made while editing a file by hand or copying an object from JavaScript or Python code. The validator explains each of these in plain words, and the ones marked auto-fix are handled by the Fix common errors button.
| Error | Example | Fix |
|---|---|---|
| Trailing comma | {"a": 1,} | Delete the comma after the last item (auto-fix) |
| Single quotes | {'a': 'b'} | Use double quotes for keys and strings (auto-fix) |
| Unquoted key | {a: 1} | Wrap the key in double quotes (auto-fix) |
| Comment | // note or /* note */ | Remove it, since JSON has no comments (auto-fix) |
| Python literals | True, False, None | Use true, false and null (auto-fix) |
| Missing comma | {"a": 1 "b": 2} | Add a comma between the two items |
| Leading zero | {"zip": 02134} | Quote it as a string: "02134" |
| Line break inside a string | "line one, then Enter" | Write the break as \n inside the string |
| NaN or Infinity | {"x": NaN} | Use null or a real number (auto-fix writes null) |
How the validator finds the error
Validation happens in two passes. First, your browser's own JSON parser reads the text. If it succeeds, the JSON is valid and the result shows its type, nesting depth and size in characters and UTF-8 bytes. Because this is the same parser your front-end code uses, a pass here means JSON.parse will accept it too.
If the browser parser fails, a second, stricter reader walks through the text from the start. It tracks every opening brace and bracket, every key and value, and stops at the first character that breaks the rules. That position is turned into a line and column, and the reader describes what it expected at that point, such as a comma or a closing brace.
The raw message from your browser is shown as well, because browsers word their errors differently and some give no position at all. Only the first error is reported, since everything after it could be misread once the structure is broken.
After a successful parse, two more checks run on the raw text. Duplicate keys are reported because JSON.parse keeps only the last one without saying so, and number literals longer than JavaScript can store are flagged before they are silently rounded. The Standard menu can also enforce the older RFC 4627 rule that the top level must be an object or an array.