This week's tip of the week is Valibot, a schema validation library that's like Zod but smaller, faster, and built for what's next.
First off, no shade to Zod, it’s awesome and seems to be the de facto standard in TypeScript used across tools like tRPC and TanStack Router that lean on it for schema validation. You can't go wrong with it.
Valibot's creator, Fabian Hillier, and Zod's creator, Colin McDonnell, teamed up to define Standard Schema: a shared open format that lets validation libraries interoperate. That means Valibot isn't competing with Zod. It's evolving the schema validation space.
Here's an example of Valibot in action:
import { object, string, number, parse } from 'valibot'
const UserSchema = object({
name: string(),
age: number(),
})
const user = parse(UserSchema, {
name: 'Boris',
age: 34,
})
console.log(user)
// -> { name: 'Boris', age: 34 }
Looks familiar, right? That's intentional. The API feels like Zod, but with one key difference: Valibot uses a functional, pipeline-based approach instead of method chaining. So where Zod does z.string().min(3).optional(), Valibot does pipe(string(), minLength(3), optional()). It's a small shift that makes the library more tree-shakeable and lighter.
Under the hood, Valibot is up to 10x faster in benchmarks and has a fraction of the bundle size. Perfect if you're working on a performance-sensitive app or shipping code to the edge.
Want to see an example in the wild? Check out this PR of mine from when I worked at OpenSauced.
Wanna learn more about Valibot? I did a couple of livestreams with Fabian where we go into the details. You can check them out on my YouTube channel.
Again, Zod is awesome, but I think it’s worth giving Valibot a look.
That's it! Short and sweet. Until the next one!

