Skip to content
Latchkey

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

  1. Open the file at the reported line:column.
  2. Remove trailing commas and comments; use double quotes.
  3. Re-run pre-commit run check-json --all-files.
Terminal
python -m json.tool tsconfig.json > /dev/null && echo OK

Exclude 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 .json files free of comments and trailing commas.
  • Exclude known JSONC files from check-json.
  • Run pre-commit locally before pushing.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →