Below are benchmark results for several node.js JSON validation modules.
This is an update to a post I made 6 months ago.
The following modules are benchmarked:
- is-my-json-valid 1.3.7https://github.com/mafintosh/is-my-json-valid
- amanda 0.5.1https://github.com/apiaryio/Amanda
- jayschema 0.2.8https://github.com/natesilva/jayschema
- json-gate 0.8.21https://github.com/oferei/json-gate
- json-schema 0.2.2https://github.com/kriszyp/json-schema
- JSV 4.0.2https://github.com/garycourt/JSV
- schema 0.2.1https://github.com/akidee/schema.js
- tv4 1.1.0https://github.com/geraintluff/tv4
- z-schema 3.0.0https://github.com/zaggino/z-schema
All modules validate with the JSON schema described here: http://json-schema.org/
I used the latest schema version supported by each module. This is noted as (v2) (v3) or (v4).
20,000 valid and 20,000 invalid JSON objects were pre-generated with random data. Each validator module was tested against the same randomized objects.
Results - Valid Objects
Results - Invalid Objects
is-my-json-valid is the fastest validator for both valid and invalid objects.
It's so fast I had to make sure it was actually doing anything at all. Amazingly fast!
tv4 is still plenty fast validating valid objects but is a bit slow dealing with invalid ones.
Jayschema remains the slowest validator.
Lastly, a reminder, amanda only supports async validation and so that test includes some additional overhead in dealing with callbacks.
Full source code for all the tests can be found here: https://github.com/Sembiance/cosmicrealms.com/tree/master/sandbox/benchmark-of-node-dot-js-json-validation-modules-part-3