
Valibot Has a Free Validation Library That's 98% Smaller Than Zod — Tree-Shakeable Schema Validation
The Bundle Size Problem Zod is great but ships 14KB minified to every user. For a simple email validation, that's overkill. Valibot is tree-shakeable. Import only what you use. A simple schema compiles to <1KB. What Valibot Gives You Modular API import * as v from ' valibot ' ; const UserSchema = v . object ({ name : v . pipe ( v . string (), v . minLength ( 1 )), email : v . pipe ( v . string (), v . email ()), age : v . optional ( v . pipe ( v . number (), v . integer (), v . minValue ( 0 ))), }); type User = v . InferOutput < typeof UserSchema > ; Same concept as Zod. Pipe-based API enables tree-shaking — unused validators don't ship. Parse and Validate // Throws on error const user = v . parse ( UserSchema , requestBody ); // Safe parse const result = v . safeParse ( UserSchema , requestBody ); if ( result . success ) { console . log ( result . output . name ); } else { console . log ( result . issues ); } Transform const TrimmedEmail = v . pipe ( v . string (), v . trim (), v . to
Continue reading on Dev.to JavaScript
Opens in a new tab



