Open your terminal and run:
git clone git@github.com:typescript-tutorial/data-validation-benchmark.git
Make sure you have Node.js and npm installed. Then run:
npm install
Run the Benchmark with typescript directly:
npx tsx ./src/app.ts
Library | Ops/sec | RME (%) | Samples | Size (min+gz) | Relative Speed (vs fastest) | Note |
---|---|---|---|---|---|---|
Ajv | 16,135,745.76 | 0.22% | 98 | ~114 KB | 🏆 1.00× (fastest) | Maximum throughput, heavier bundle |
xvalidators | 1,837,148.5 | 0.18% | 98 | ~3.8 KB | ~8.8× slower | Small + fast for edge/API |
Zod | 1,286,858.66 | 1.21% | 97 | ~25 KB | ~12.5× slower | Medium Size + Good Performance |
Valibot | 1,200,122.07 | 0.21% | 98 | ~4 KB | ~13.4× slower | Small Size + Good Performance |
Joi | 382,176.91 | 0.26% | 98 | ~80 KB | ~42.2× slower | Heavy Size + Slow Performance |
Yup | 139,092.61 | 0.25% | 97 | ~28 KB | ~116× slower | Medium Size + Very Slow Performance |