JSON Validator
|
Paste JSON and instantly find out whether it is valid. If it is not, you get the exact parser error — position included — so you can fix the syntax without guessing.
Why JSON fails to parse
Trailing commas are the single most common cause. JSON does not allow a comma after the last element in an object or array, even though JavaScript does. A single stray comma causes the entire payload to fail.
Other frequent causes: single-quoted strings (JSON requires double quotes for every string and key), unquoted key names, missing commas between fields, mismatched braces or brackets, and control characters inside strings.
{"key": "value",} ← invalid, remove the comma{'key': 'value'} ← invalid, use double quotes{key: "value"} ← invalid, keys must be quotedWhat this tool validates
It validates JSON syntax — whether the text can be parsed by a strict JSON parser. It does not validate schema or data shape. A valid JSON file with the wrong structure for your use case will still pass here.
For schema validation — checking required fields, types, and allowed values — use a library like Ajv or Zod in your project.
Using the error position to find the problem
Parser errors include a character position (e.g., "at position 47"). Count that many characters from the very start of the JSON string — the mistake is usually at or just before that point. The parser reports where it gave up, not necessarily where you made the mistake, so look one or two tokens earlier.
A position-0 error (or "Unexpected token" on the first character) often means a byte-order mark (BOM) from some text editors, a stray character prefixed by an API response wrapper, or the literal word undefined printed where a value should be.
For large payloads, the browser console is a useful complement: paste JSON.parse(yourString) — it throws the same error with the same position, and you can then use substring arithmetic to isolate the region around the problem.
{"a":1,"b":} → error near pos 11 (the } after :); missing value is the real cause{"x":1,"y":2,} → error near pos 13; the , before } is invalidFile saved with UTF-8-BOM encoding adds an invisible byte — strip it before parsingCommon validation workflow
If you have a JSON payload that is causing a runtime error, paste it here first. A parse error almost always means the JSON is malformed before it even reaches your application logic.
If validation passes but your application still fails, the JSON is syntactically correct but likely missing a field or using the wrong type — schema validation handles that case.
See also: JSON Formatter
Frequently Asked Questions
- What is the difference between this and the JSON Formatter?
- The Formatter requires valid JSON and produces indented output. The Validator only checks whether input is parseable — it reports pass or fail and shows the error if parsing fails. Use the Validator first when you suspect syntax problems.
- Can it validate JSON with comments (JSONC)?
- No. JSON comments are not part of the JSON specification. Strip comments before validating, or use an editor with JSONC support. VS Code handles .jsonc files natively.
- Does it check against a schema?
- No. It checks syntax only — whether the text is parseable JSON. Schema validation (required keys, value types, allowed values) is out of scope and needs a dedicated library.
- My JSON passes here but my API rejects it — why?
- The JSON is syntactically valid but likely fails schema validation on the API side: a required field is missing, a value is the wrong type, or a field value is outside the allowed range. Check the API's error response for details.
- What does "Unexpected end of JSON input" mean?
- The input ends before all open brackets and braces are closed. Count your { and [ characters against your } and ] characters — one pair is mismatched or missing. This frequently happens when copying a partial payload from a log file, a network inspector, or a terminal that truncated a long response.