Compiling
June 2, 2026 ยท View on GitHub
Warning
JSON Schema Draft 2 and older are not supported at this point in time.
jsonschema compile <schema.json|.yaml> [--http/-h] [--verbose/-v] [--debug/-g]
[--header/-H "<name>: <value>"]
[--resolve/-r <schemas-or-directories> ...] [--extension/-e <extension>]
[--ignore/-i <schemas-or-directories>] [--fast/-f] [--default-dialect/-d <uri>]
[--minify/-m] [--json/-j] [--include/-n <name>] [--entrypoint/-p <pointer|uri>]
[--format-assertion/-F]
The validate command will first compile the schema into an optimised
low-level form (the compiled template) before evaluating using the
Blaze high-performance JSON Schema
compiler. This command allows you to separately compile the schema and print
the low-level template to standard output.
The low-level template is not stable across versions of this JSON Schema CLI. While it might work, we don't necessarily support evaluating templates generated with another version of this tool.
You can pass the compiled template to the validate
command to avoid expensive schema compilation if you need to perform validation
multiple times with the same schema.
Tip
The compiled template is also consumable from any JavaScript engine through the Blaze JavaScript port, a pure-JavaScript evaluator for browsers and JavaScript runtimes like Node.js. Compile once with this CLI and evaluate anywhere.
Warning
By default, schemas are compiled in exhaustive mode, which results in better
error messages and annotations, at the expense of speed. The --fast/-f
option makes the schema compiler optimise for speed, at the expense of error
messages.
Compile a standalone JSON Schema in exhaustive mode
jsonschema compile path/to/my/schema.json > template.json
Compile a standalone JSON Schema in optimised mode
jsonschema compile path/to/my/schema.json --fast > template.json
Compile a JSON Schema forcing every format to assert
The --format-assertion/-F option bakes format assertion behavior into the
template, so every format keyword becomes an assertion regardless of dialect
or vocabulary at evaluation time.
jsonschema compile path/to/my/schema.json --format-assertion > template.json
Compile a JSON Schema resolving one of its dependencies
jsonschema compile path/to/my/schema.json --resolve other.json > template.json
Compile a JSON Schema to a C/C++ header file
jsonschema compile path/to/my/schema.json --include MY_SCHEMA > my_schema.h
Compile a specific subschema by JSON Pointer
jsonschema compile path/to/my/schema.json --entrypoint '/$defs/MyType' > template.json
Compile a JSON Schema with a custom HTTP header
jsonschema compile path/to/my/schema.json \
--http --header "Authorization: Bearer $REGISTRY_TOKEN"