What is checked
The validator uses the strict JSON rules of the standard (RFC 8259, the same as ECMA-404). That is what JSON.parse in a browser, json.loads in Python and most APIs accept. It reports the first error with its line, column and a short message, and shows the line with a marker under the problem.
Warnings for valid JSON
Some JSON is valid but still causes trouble. The validator warns you about:
- Duplicate keys. The standard allows them, but parsers keep only one value, usually the last, and the others are lost silently.
- Numbers that lose precision. An integer with more than 15 digits, such as an order ID, cannot be held exactly by a JavaScript number. Store such IDs as strings.
- Numbers out of range. A value such as 1e999 becomes Infinity in many languages.
The most common JSON errors
| Mistake | Example | Fix |
|---|---|---|
| Trailing comma | {"a": 1,} | Remove the last comma |
| Single quotes | {'a': 1} | Use double quotes |
| Unquoted key | {a: 1} | Write "a" |
| Comment | // note | Remove it; JSON has no comments |
| Missing comma | {"a": 1 "b": 2} | Add a comma between the pairs |
| NaN, Infinity, undefined | {"a": NaN} | Use null or a string |
| Leading zero or plus sign | {"a": 007} | Write 7 |
| Raw line break in a string | "line 1[Enter]line 2" | Write \n instead |
| Several documents | {"a":1}{"a":2} | Put them in an array, or validate one at a time |
What the error messages mean in different languages
The same mistake produces different messages in different parsers. This tool names the problem in plain words and gives the position.
| Where | Typical message | Usual cause |
|---|---|---|
| JavaScript | Unexpected token } in JSON at position 42 | Trailing comma, or a missing value |
| JavaScript | Unexpected token < in JSON at position 0 | The server returned an HTML page, not JSON |
| JavaScript | Unexpected end of JSON input | Empty response, or a missing closing bracket |
| Python | Expecting property name enclosed in double quotes | Single quotes, an unquoted key or a trailing comma |
| Python | Expecting , delimiter | A comma is missing between two items |
| PHP | json_last_error_msg(): Syntax error | Any syntax mistake, with no position |
Newer versions of Chrome and Node word these errors differently, but the causes are the same. PHP gives no position at all, so paste the text here to find the exact spot.
Valid JSON vs JSONC, JSON5 and JSON Schema
- JSONC is JSON with comments and trailing commas, used by VS Code and TypeScript config files. A file such as tsconfig.json is not valid JSON.
- JSON5 adds single quotes, unquoted keys and more. It needs its own parser.
- JSON Schema describes what the data must look like, for example that age is a number. This validator checks syntax only. A document can be valid JSON and still be wrong for your API.
Why JSON from an API can be invalid
- The response is an error page in HTML.
- A byte order mark comes before the first brace. This tool ignores it, but some parsers reject it.
- Text was copied from a chat or word processor, which replaced straight quotes with curly quotes.
- The data was printed with single quotes, as a Python dict or a JavaScript object does.
- The text was cut off, for example by a log size limit.
Repair suggestion
When the only problems are comments and trailing commas, the tool says so and shows a repaired, formatted version that you can copy. For other errors, fix the marked spot and the check runs again as you type.
Privacy
Validation happens in your browser. The JSON is not sent anywhere.
Next: format or minify the valid JSON, or compare it with another document. If you work with YAML, see the JSON YAML converter. The JSON minification guide covers pitfalls such as big numbers.