JSON Validation and Common Errors/Validate with Python json.tool

Check syntax and pretty-print if valid.

Section: Validate JSON files

Validate with Python json.tool

bash
bash
python -m json.tool input.json
Explanation

A built-in option that many systems already have.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Validate JSON files
Validate with jq
Parse a file and fail if JSON is invalid.
OpenIn sheetbashsame section
Validate with Node.js
Parse a file with JavaScript runtime tooling.
OpenIn sheetbashsame section
Single quotes are invalid
Strings and keys must use double quotes.
OpenIn sheetjson1 tag match
Trailing commas are invalid
Do not leave a comma after the last item.
OpenIn sheetjson1 tag match
Object keys must be quoted
Bare identifiers are invalid in JSON.
OpenIn sheetjson1 tag match
Raw newlines inside strings are invalid
Use `\n` rather than an actual line break inside a string literal.
OpenIn sheetjson1 tag match