check-jsonschema is a command-line interface (CLI) tool and pre-commit hook for validating JSON/YAML files against JSON schemas. It provides a convenient way to integrate schema validation into development workflows, supporting a wide range of common configuration schemas. The current version is 0.37.1, and it releases frequently to update vendored schemas and add new features.
pip install check-jsonschemaVerified import paths — ran on the pinned version, not inferred.
The primary use of check-jsonschema is through its command-line interface or as a pre-commit hook. First, define your JSON schema and the data you wish to validate. Then, run the `check-jsonschema` command specifying the schema and data files. For automated checks, configure it in your `.pre-commit-config.yaml` file, using its built-in hooks for common configuration files or a custom hook for your own schemas.
Ensure your environment uses Python 3.10 or newer. Upgrade your Python version or pin check-jsonschema to a version prior to 0.37.0 if Python 3.9 is required.
If you relied on `-v` to see filenames, adjust your scripts or commands to use `-vv` instead for that output.
Verify that your `pre-commit` hook configuration correctly points to schemas, especially if they are not vendored. Use the `--schema` argument with a correct relative path if validating against a local schema, or ensure your schema's `$id` is properly set up for external resolution.
Always explicitly specify your custom schema using `--schema your-custom-schema.json` if it's not one of the vendored types or if you need to override the default. For `pre-commit` hooks, configure a specific hook to point to your custom schema.