Introduction
TypeBox performance meets Zod ergonomics - with streaming validation
valrs
valrs is a schema validation library that combines TypeBox-level performance with Zod's developer experience. Written in Rust and compiled to WebAssembly, it delivers near-native validation speeds while providing a familiar, chainable API.
Why valrs?
Zod-Compatible API
If you know Zod, you know valrs. The API is designed to be a drop-in replacement:
TypeBox-Level Performance
valrs is built in Rust and compiled to WebAssembly, delivering validation speeds competitive with the fastest JavaScript validators:
| Library | ops/sec | Relative |
|---|---|---|
| TypeBox | 22.75M | 1.04x |
| valrs | 21.84M | baseline |
| ArkType | 7.73M | 0.35x |
| Valibot | 2.11M | 0.10x |
| Zod | 1.45M | 0.07x |
Streaming Validation (Killer Feature)
Validate massive JSON files with O(1) memory. No other validation library offers this:
Full Zod Feature Parity
valrs implements the complete Zod API:
- Primitives: string, number, bigint, boolean, date, null, undefined, void, any, unknown, never
- Objects: object, extend, merge, pick, omit, partial, deepPartial, strict, passthrough, strip
- Collections: array, tuple, record, map, set
- Unions: union, discriminatedUnion, intersection, literal, enum, nativeEnum
- Modifiers: optional, nullable, nullish, default, catch
- Transforms: transform, refine, superRefine, pipe, preprocess, coerce
Quick Migration from Zod
Migrating from Zod is straightforward - change z to v:
Portability
- Browsers: Uses WebAssembly for maximum performance
- Node.js: Pure JavaScript fallback works everywhere
- Edge: Compatible with Cloudflare Workers and other edge runtimes
Standards Compliance
valrs implements the Standard Schema specification v1, enabling interoperability with any tool that supports the standard.
Next Steps
- Getting Started - Installation and setup
- Primitives - String, number, boolean, and more
- Custom Schemas - Build your own schema types
- JSON Schema - Generate JSON Schema from valrs schemas
- Standard Schema - Interoperability with Standard Schema v1
- API Reference - Complete API documentation