Skip to content

sagold/json-schema-benchmark

 
 

Repository files navigation

json-schema-benchmark (draft7)

Performance benchmark for Node.js JSON-schema validators.

[2022/04/23] The purpose of this fork is just to have an updated benchmark result for the current state of supported draft features and their performance. I have no intention on maintaining this repository.

Changes made:

  • updated ajv setup and integrated ajv formats plugin
  • changed default draft to draft 07
  • updated benchmark results

[2022/11/13] updated libraries and rerun benchmark [2024/04/05] updated libraries and rerun benchmark

Also tests against official JSON-schema test suite, version draft7. and checks for validators that cause side-effects on schema or data. The top 6 validators that fail the least tests are included in the benchmark.

Contribute to these benchmarks

Performance

performance

Validator Relative speed Number of test runs per second
@exodus/schemasafe 100% 29168 (± 0.17%)
ajv 85.7% 25010 (± 0.15%)
djv 13.3% 3881 (± 0.19%)
@cfworker/json-schema 4.4% 1272 (± 1.17%)
json-schema-library 2.1% 615 (± 0.21%)
jsonschema 1% 301 (± 0.4%)

1049 tests are run in each test run.

Validators tested: json-schema-library (9.3.4), @cfworker/json-schema (1.12.8), jsonschema (1.4.1), ajv (8.12.0), @exodus/schemasafe (1.3.0), djv (2.1.4), is-my-json-valid (2.20.6), jsen (0.6.6), tv4 (1.3.0), jjv (1.0.2), jassi (0.1.2), z-schema (6.0.1), request-validator (0.3.3), json-schema-validator-generator (1.1.11), themis (1.1.6), JSV (4.0.2), json-model (0.2.24), jsck (0.3.2), skeemas (1.2.5), schemasaurus (0.7.8), json-gate (0.8.23), revalidator (0.3.1),

(validators not in the results above where excluded because of failing tests - see below for details)

@exodus/schemasafe is currently the fastest JSON-schema validator out there.

Test failure summary

This test suite uses the official JSON-schema test suite, version draft7.

If a validator does not pass a test in the official test suite, it will show up in these results.

failing tests

Validator Number of failing tests (click for details)
json-schema-library 41
@cfworker/json-schema 41
jsonschema 46
ajv 58
@exodus/schemasafe 101
djv 157
is-my-json-valid 164
jsen 198
tv4 212
jjv 229
jassi 229
z-schema 249
request-validator 264
json-schema-validator-generator 273
themis 275
JSV 291
json-model 291
jsck 341
skeemas 361
schemasaurus 378
json-gate 420
revalidator 449

Some validators have deliberately chosen not to support parts of the spec. Go to the homepage of the validator to learn if that is the case for these tests.

Side-effects summary

Number of tests that caused side-effects. The schema or data was altered by the validator.

Validator Number of side-effects (BAD)
json-model 981
revalidator 983

Validators not in the list have no side-effects on data or schemas.

Tests for other JSON-schema versions

Features of validators

Note that these benchmarks and tests do not take into account other more advanced features of the validators. I encourage you to take a look at each validator if you are looking for special features.

Benchmarks by validator authors and others

Several of the validators have build benchmarks themselves. They are more detailed then the benchmarks provided above.

Benchmarks owned by z-schema

Benchmarks owned by themis

Benchmarks owned by jsck

There is also a benchmark suite by cosmicrealms.

License

MIT

About

Benchmarks for Node.js JSON-schema validators

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%