JSON Validation and Common Errors/Rewrite valid JSON in normalized form

Read and immediately re-emit clean JSON.

Section: Common parse failures

Rewrite valid JSON in normalized form

bash
bash
jq . broken-or-ugly.json > normalized.json
Explanation

This is useful once the file parses and you want a canonical pretty form.

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 Common parse failures
Single quotes are invalid
Strings and keys must use double quotes.
OpenIn sheetjsonsame section
Trailing commas are invalid
Do not leave a comma after the last item.
OpenIn sheetjsonsame section
Object keys must be quoted
Bare identifiers are invalid in JSON.
OpenIn sheetjsonsame section
Raw newlines inside strings are invalid
Use `\n` rather than an actual line break inside a string literal.
OpenIn sheetjsonsame section
Validate with jq
Parse a file and fail if JSON is invalid.
OpenIn sheetbash2 tag match
Validate with Python json.tool
Check syntax and pretty-print if valid.
OpenIn sheetbash1 tag match