{"id":1961,"library":"check-jsonschema","title":"check-jsonschema","description":"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.","status":"active","version":"0.37.1","language":"en","source_language":"en","source_url":"https://github.com/python-jsonschema/check-jsonschema","tags":["jsonschema","validation","cli","pre-commit","schema","yaml","json"],"install":[{"cmd":"pip install check-jsonschema","lang":"bash","label":"Install via pip"},{"cmd":"pip install pre-commit && pre-commit install","lang":"bash","label":"Install pre-commit (if not already)"}],"dependencies":[{"reason":"Core dependency for schema validation logic.","package":"jsonschema","optional":false}],"imports":[{"note":"check-jsonschema is primarily a CLI tool and a pre-commit hook. Direct programmatic import and execution of its internal `main` function is not a common use case and is generally discouraged in favor of the CLI.","symbol":"main","correct":"from check_jsonschema.main import main"}],"quickstart":{"code":"# 1. Create a schema file (e.g., 'my_schema.json')\n# echo '{\"type\": \"object\", \"properties\": {\"name\": {\"type\": \"string\"}}, \"required\": [\"name\"]}' > my_schema.json\n\n# 2. Create a data file to validate (e.g., 'my_data.json')\n# echo '{\"name\": \"John Doe\"}' > my_data.json\n\n# 3. Run validation via CLI\n# check-jsonschema --schema my_schema.json my_data.json\n\n# 4. Integrate with pre-commit (add to .pre-commit-config.yaml)\n#    - repo: https://github.com/python-jsonschema/check-jsonschema\n#      rev: '0.37.1'\n#      hooks:\n#        - id: check-dependabot\n#        - id: check-github-workflows","lang":"bash","description":"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."},"warnings":[{"fix":"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.","message":"Python 3.9 support has been dropped.","severity":"breaking","affected_versions":">=0.37.0"},{"fix":"If you relied on `-v` to see filenames, adjust your scripts or commands to use `-vv` instead for that output.","message":"Verbose output levels for the CLI have changed. Previously, `-v` showed checked filenames; now, `-v` shows all errors without filenames, and `-vv` (or higher) is required to display filenames checked.","severity":"breaking","affected_versions":">=0.37.0"},{"fix":"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.","message":"When using check-jsonschema as a pre-commit hook with custom schemas, ensure the schema paths are correct relative to the repository root or accessible via defined `$schema` IDs. Incorrect paths or unreachable references will lead to validation errors.","severity":"gotcha","affected_versions":"all"},{"fix":"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.","message":"check-jsonschema defaults to validating against vendored schemas for common config types (e.g., GitHub Workflows, Dependabot). If you have a custom schema with the same filename or an unconventional path, it might be ignored or validated against the wrong schema.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}