I have updated this post here: Benchmark of node.js JSON Validation Modules Part 3
Below are benchmark results for several node.js JSON validation modules.
This is an update to a post I made 2 years ago.
The following modules are benchmarked:
- amanda 0.4.7https://github.com/Baggz/Amanda
- jayschema 0.2.3https://github.com/natesilva/jayschema
- joi 2.5.0https://github.com/spumko/joi
- 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.0.12https://github.com/geraintluff/tv4
- z-schema 2.4.3https://github.com/zaggino/z-schema
All modules validate with the JSON schema described here: http://json-schema.org/ except for joi which uses a custom schema.
I used the latest schema version supported by each module. This is noted as (v2) (v3) or (v4).
tv4 appears to be the fastest, but it only supports the very latest v4 JSON schema version. So if you have older schema documents, you'll need to go with one of the others.
Jayschema takes the 'slowest validator' crown away from JSV. I'd avoid using it if performance matters to your application.
It should be noted that joi doesn't support the JSON schema specification. Joi uses a custom schema which does not support checking for unique array items or evenly divisible numbers.
Lastly, 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-2