What Is JSON Schema? Validating JSON Explained
JSON Schema is a vocabulary for describing the allowed structure of a JSON document so it can be validated automatically.
JSON Schema is JSON that describes other JSON. It lets you declare which fields are required, what types they must be, and what values are allowed, so a validator can check a document against the rules. Because YAML is a superset of JSON, the same schemas power the editor autocomplete and validation you get on workflow files.
What JSON Schema is
A JSON Schema is itself a JSON document that defines constraints: required properties, allowed types, value ranges, enumerations, and nested object shapes. You hand a validator the schema and a document, and it tells you whether the document conforms and exactly where it does not.
Why schemas matter
Schemas turn "I think this config is right" into a machine-checkable guarantee. They catch typos in field names, missing required values, and wrong types before a tool ever tries to use the file. They also document the expected shape in a precise, executable way.
Editor autocomplete and validation
Editors use JSON Schemas to power autocomplete and inline error squiggles. The reason your editor knows the valid keys in a GitHub Actions workflow or a package.json is that a published schema describes those files, and the editor validates as you type.
JSON Schema in CI
In CI you can add a validation step that checks config files against their schemas before doing real work - failing fast on a malformed workflow, manifest, or app config. This is cheap insurance against a bad config slipping through and breaking a later, slower stage.
# Validate a config file against a schema in CI
steps:
- run: npm install -g ajv-cli
- run: ajv validate -s schema.json -d config.jsonLatchkey note
Schema-validation steps are just CLI runs and they pull small npm or pip packages. On Latchkey those dependencies are cached between runs, so a fast "validate config" gate stays fast on every push.
Key takeaways
- JSON Schema is JSON that describes the required structure, types, and allowed values of a document.
- It powers editor autocomplete and validation for files like workflows and package.json.
- A schema-validation step in CI catches malformed config early, before slower stages run.