A comparison of popular TypeScript runtime validation libraries.
Because bundlejs.com didn't mange to properly extract the actual bundle size of some of the libraries usage.
Also, I was not convinced by some other comparisons online and wanted to compare popular solutions and their variations based on several criteria:
- Runtime performance
- Actual bundle size for a typical usage
- Development experience
Note:
It's not clear at the moment why v4 drops in performance.
Perhaps something to do with the bundle importing.
Package | Actual Bundle Size | bundlejs size | Runtime Performance | Docs | DX |
---|---|---|---|---|---|
Zod v3 | 14.88 kB (gzip) | 14.4 kB (gzip) | Fastest | Ok | Good |
Zod v4 | 14.46 kB (gzip) | 46.8 kB (gzip) | Slow for some reason | ||
Zod v4 Mini | 5.28 kB (gzip) | 44.8 kB (gzip) | Slow for some reason | ||
Valibot | 1.95 kB (gzip) | 1.67 kB (gzip) | Zod is 1.3x faster | Good | Good |
Valibot with * as v |
1.96 kB (gzip) | 13.4 kB (gzip) | |||
ArkType | 55.82 kB (gzip) | 45.9 kB (gzip) | Zod is 15x faster | Good | Weird, need extra tools |
pnpm i
To see the benchmark results:
pnpm run bench
To see the bundle size results:
pnpm run build