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.
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.
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).
- 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.