I’ve been using Zod for TypeScript validation, but I kept running into performance bottlenecks in high-throughput applications. So I built DHI – a WebAssembly-powered validation library that offers a familiar Zod-like API while being significantly faster.
Why I Built This:
• Zod is great, but it slows down at scale, especially with large datasets.
• DHI uses WebAssembly to execute validations at near-native speeds.
• It’s TypeScript-first and async-friendly, with built-in support for batch validation.
• I love to build things and this was just a passion project that I did in a day
Benchmarks (for 1,000,000 validations):
Library | Time Taken (ms) | Validations per sec
DHI | 3010.11 | 332,214 Zod | 5679.42 | 176,074
Features:
• Familiar API inspired by Zod.
• WebAssembly-powered for ultra-fast validation.
• Supports batch validation for high-throughput processing.
• Minimal memory overhead.
• Supports all major TypeScript types.
Example Usage:
import { dhi } from ‘dhi’;
const UserSchema = await dhi.object({ name: dhi.string(), age: dhi.number(), email: dhi.string() });
const result = UserSchema.validate({ name: “John”, age: 30, email: “john@example.com” });
console.log(result.success); // true or false
Would love your thoughts! Is this something you’d use in your projects? What’s been your biggest frustration with TypeScript validation?
There is also a live website to see the speed difference for yourself: https://dhi.trilok.ai