How the JSON validator works
Paste JSON into the left editor and click Validate (or press Ctrl + Enter). The text is parsed with your browser's built-in JSON.parse, the same strict parser your JavaScript code uses. If parsing fails, the error message from the parser is shown above the editors. If it succeeds, the right editor shows a normalized copy: re-serialized with the indent you picked (2 spaces, 4 spaces, or minified), and with keys sorted alphabetically if Sort Keys is on.
Normalizing is useful on its own. Two JSON files that differ only in whitespace or key order produce identical output with Sort Keys enabled, so you can compare them line by line.
The five errors that break most JSON
Almost every "invalid JSON" report comes down to one of these. Each example below fails validation, followed by the fix.
1. Trailing comma
{ "name": "Ada", "role": "admin", }
JavaScript object literals allow a comma after the last item. JSON does not. Delete the final comma: { "name": "Ada", "role": "admin" }.
2. Single quotes
{ 'name': 'Ada' }
Strings and keys must use double quotes. Single quotes usually appear when JSON is copied from Python output or hand-written JavaScript.
3. Unquoted keys
{ name: "Ada" }
Every key must be a quoted string, even when it is a simple word.
4. Comments
{
"port": 8080 // default port
}
JSON has no comment syntax. Files like tsconfig.json accept comments because their tools use a relaxed parser, not because the JSON is valid.
5. Values JSON does not support
{ "total": NaN, "next": undefined, "big": 0x1F }
NaN, Infinity, undefined, and hexadecimal numbers are JavaScript values, not JSON. Use null or a plain decimal number instead.
If your data has several of these problems at once, run it through the JSON Repair tool first, which fixes the common cases automatically, then validate the result here.
Reading the error message
The message comes from your browser, so the wording differs slightly between Chrome, Firefox, and Safari. Most include a position. For a trailing comma, Chrome reports "Expected double-quoted property name in JSON at position 34". The position counts characters from the start of the text, beginning at 0. The real mistake is usually just before that point: a missing comma between two items, or an extra comma before a closing bracket.
What valid JSON does not guarantee
- Correct structure. The validator checks syntax, not meaning.
{"age": "forty"} is valid JSON even if your API expects a number.
- Unique keys.
{"id": 1, "id": 2} parses without error. The last value wins, so the output shows only "id": 2. If a key disappears in the output, check for a duplicate.
- Number precision. Integers larger than 9,007,199,254,740,991 lose precision in JavaScript. A 19-digit ID will be rounded in the normalized output. Store large IDs as strings.
When to use a different tool
- To pretty-print JSON you already know is valid, use the JSON Formatter.
- To convert validated JSON for a config file, use JSON to YAML.
- To edit JSON with syntax highlighting and folding, open the JSON Editor.
Frequently asked questions
Why does my JSON fail with "Unexpected token"?
The parser hit a character that is not allowed at that position. The most common causes are a trailing comma after the last item, single quotes instead of double quotes, an unquoted key, or a comment. The error message includes the position, so check the character just before it.
Is JSON with comments or trailing commas valid?
No. Standard JSON (RFC 8259) does not allow comments or trailing commas. Formats such as JSONC and JSON5 do, and some tools like VS Code settings accept them, but a strict parser like JSON.parse will reject them. Remove them, or use the JSON Repair tool to strip them automatically.
Does this validator check my data against a JSON Schema?
No. It checks syntax only: whether the text is well-formed JSON. It does not check that required fields exist or that values have the right type. For that you need a JSON Schema validator.
What does Sort Keys do?
When enabled, object keys are sorted alphabetically at every level of nesting in the output. Array order is never changed. This is useful for comparing two JSON documents in a diff tool.
Is my JSON sent to a server?
No. Validation runs in your browser with the built-in JSON.parse function. Pasted text and imported files are not uploaded. Import URL fetches the file directly from your browser.