Warning
JSON Schema Draft 3 and older are not supported at this point in time.
jsonschema compile <schema.json|.yaml> [--http/-h] [--verbose/-v] [--debug/-g]
[--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>]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.
jsonschema compile path/to/my/schema.json > template.jsonjsonschema compile path/to/my/schema.json --fast > template.jsonjsonschema compile path/to/my/schema.json --resolve other.json > template.jsonjsonschema compile path/to/my/schema.json --include MY_SCHEMA > my_schema.hjsonschema compile path/to/my/schema.json --entrypoint '/$defs/MyType' > template.json