Introduction
Ultra-fast schema validation - 12x faster than Zod, 6x faster than Valibot
Vex is an ultra-fast schema validation library for TypeScript. It's designed with pure functional principles, delivering exceptional performance with zero overhead.
Why Vex?
lucide:zap
Lightning Fast
12x faster than Zod, 6x faster than Valibot. Benchmarked with real-world schemas.
lucide:feather
Zero Overhead
Validators are constants, not factory functions. No allocation on every call.
lucide:shield-check
Type Safe
Full TypeScript inference with accurate types. No manual type annotations needed.
lucide:trees
Tree Shakeable
Import only what you need. Dead code elimination works perfectly.
Quick Start
npm install @sylphx/veximport { str, num, object, email, int, positive, safeParse } from '@sylphx/vex'
const userSchema = object({
name: str(),
email: str(email),
age: num(int, positive),
})
// Throws on error
const user = userSchema(data)
// Or use safeParse for result objects
const result = safeParse(userSchema)(data)
if (result.success) {
console.log(result.data)
} else {
console.log(result.error)
}Pure Functional Design
Unlike other validation libraries, Vex uses a pure functional approach:
// Vex - validators are constants, zero allocation
str // constant
str(email) // compose with constraints
// Others - allocates on every call
z.string().email() // Zod
v.string() // ValibotThis design eliminates runtime overhead and enables maximum tree-shaking.