How to Validate JSON
Valid JSON is text that JSON.parse accepts. Validation does not pretty-print or minify; it only reports whether the document is legal JSON.
By Andreas RosenbergUpdated
The test
If JSON.parse(text) succeeds, the text is valid JSON. If it throws, it is not. A validator that only checks braces by eye will miss a trailing comma.
{
"name": "Ada",
"ok": true
}parses. This does not:
{
"name": "Ada",
}Steps
- Paste the document you intend to send or store — not a screenshot.
- Run Validate. On the MultiConvers JSON formatter, that leaves your spacing alone and only reports parse success or failure.
- If it fails, read the line and column, then look for a trailing comma, a missing quote, or a comment.
A worked failure
This document looks finished and is not:
{
"name": "Ada",
}The comma after "Ada" claims another property follows. Nothing does, so JSON.parse stops at that comma. Delete the comma and the same object parses. The line and column on the formatter are a starting point for that comma, not a schema review.
The limit
A document that parses can still be the wrong document. Missing "email" is valid JSON if your text never promised that field. This check is syntax only. It does not apply a JSON Schema, and it does not pretty-print.
Common failures
| Input | Why it fails |
|---|---|
{"a": 1,} | Trailing comma |
{a: 1} | Unquoted key |
{'a': 1} | Single quotes |
After it parses, format or pretty-print if you need to read it.
FAQ
- Does valid JSON mean my schema is right?
No. Parse only checks JSON syntax. A missing field your API needs is still valid JSON.
- Why is the line number only approximate?
Engines often report a character offset. Converting that to a line and column depends on newline style. Use it as a starting point.
Related guides
How to Format JSON
Formatting JSON means parsing it, then reprinting the same value with consistent indentation. Invalid text cannot be formatted — fix the syntax first.
JSON Pretty Print
Pretty-print reprints valid JSON with indentation so a person can read it. Minify reprints the same value as one line. Neither changes what the document means.
Related tools
See all guides.