pre-commit "check-json...Failed" in CI
The pre-commit check-json hook parses every staged .json file. Strict JSON forbids comments and trailing commas, so a file with either fails with "check-json...Failed".
What this error means
pre-commit output shows "check-json...............Failed" with a JSON decode error like "Expecting property name enclosed in double quotes" and the filename.
pre-commit
check-json...............................................................Failed
- hook id: check-json
- exit code: 1
tsconfig.json: Failed to json decode (Expecting ',' delimiter: line 8 column 3 (char 210))Common causes
A trailing comma or comment
JSON does not allow trailing commas or // comments; check-json parses strictly and rejects them.
A JSONC file validated as strict JSON
Files like tsconfig.json are often JSONC (comments allowed by tools) but check-json treats .json as strict JSON.
How to fix it
Make the file strict JSON
- Open the file at the reported line:column.
- Remove trailing commas and comments; use double quotes.
- Re-run
pre-commit run check-json --all-files.
Terminal
python -m json.tool tsconfig.json > /dev/null && echo OKExclude JSONC files from check-json
If a file legitimately uses comments, exclude it from check-json (validate it with a JSONC-aware tool instead).
.pre-commit-config.yaml
- id: check-json
exclude: ^(tsconfig\.json|\.vscode/.*\.json)$How to prevent it
- Keep strict
.jsonfiles free of comments and trailing commas. - Exclude known JSONC files from check-json.
- Run pre-commit locally before pushing.
Related guides
check-jsonschema "Invalid JSON" parse error in CIFix check-jsonschema "Failed to parse ...: Invalid JSON" in CI - the instance or schema file is not valid JSO…
pre-commit "check-yaml...Failed" in CIFix pre-commit "check-yaml...Failed" in CI - the check-yaml hook could not parse a YAML file (syntax error, t…
pre-commit "end-of-file-fixer...Failed" in CIFix pre-commit "end-of-file-fixer...Failed" in CI - the hook modified files to end in a single newline. In CI…