What a JSON Checker Reports
A syntax check answers one question: does this text conform to the JSON grammar? It does not judge whether the fields are the ones your API expects — that is a schema check. What it gives you is certainty that JSON.parse() will not throw.
Checker Output
- Status — valid or invalid, updated as you type.
- Error position — the line and column where the parser stopped.
- Structure statistics — key count, maximum nesting depth, and byte size.
Syntax Check vs Schema Check
Two different failures look the same from the outside. {"age": "thirty"} passes a syntax check and fails a schema check that requires an integer. {"age": 30,} fails the syntax check and never reaches the schema. Check syntax first; it is the cheaper and more common fault.
Checking JSON on the Command Line
# jq exits non-zero on invalid JSON
jq empty file.json
# Python, with the error position printed
python3 -m json.tool file.json > /dev/nullWho this guide is for
- Check a config file before a deploy that would fail on a parse error
- Confirm a fixture file is well-formed before committing it
- Check a payload pasted from a bug report against the spec
- Verify an editor did not corrupt a file with smart quotes