Valibot v1 - The 1 kB schema library

I am excited to announce the release of Valibot v1. Valibot is a modular and fully tree-shakable schema library that helps you describe and validate your data with a type-safe and easy-to-remember API. As a 1 kB alternative to Zod, Valibot is perfect for validating forms and securing backend-frontend communication with a single source of truth.
How everything started
Some of you may remember my introduction post that I published on Builder.io in July 2023 with my supervisors Miško Hevery (creator of Angular and Qwik) and Ryan Carniato (creator of SolidJS). Back then, as part of my bachelor thesis, I was investigating how to drastically reduce the bundle size of JavaScript libraries by more then 90%. As part of my research, I analysed Zod, ArkType and Typia, and created with Valibot a new schema library from scratch.
If all this makes you curious, you should definitely check out the talk I gave last October at the web development meetup I hosted with Miško Hevery and Rich Harris at Pace University.
How the 1 kB thing works
Similar to how types can be defined in TypeScript, Valibot allows you to define a schema with various small functions. This applies to primitive values like strings as well as to more complex data sets like objects. In addition, the library helps to perform more detailed validations and transformations with the help of pipelines.
import * as v from 'valibot'; // 1.31 kB
// Create login schema with email and password
const LoginSchema = v.object({
email: v.pipe(v.string(), v.email()),
password: v.pipe(v.string(), v.minLength(8)),
});
// Infer output TypeScript type of login schema as
// { email: string; password: string }
type LoginData = v.InferOutput<typeof LoginSchema>;
// Throws error for email and password
const output1 = v.parse(LoginSchema, { email: '', password: '' });
// Returns data as { email: string; password: string }
const output2 = v.parse(LoginSchema, {
email: 'jane@example.com',
password: '12345678',
});
Instead of relying on a few large classes or functions with many methods, Valibot's API design is based on many small and independent functions. Each with just a few lines of code and a single task. This modular design has several advantages.
On the one hand, it provides the flexibility to replace and extend Valibot's functions with custom code. On the other hand, it makes the source code more robust and secure, because the functionality of a single function as well as special edge cases can be tested more specifically. This makes it easy for us to achieve 100% test coverage, reducing bugs to a minimum.
However, perhaps the biggest advantage is that a bundler like Rolldown or Rspack can use the static import statements to remove any code that is not needed. Thus, only the code that is actually used ends up in your production build. This allows us to extend the functionality of the library without increasing your individual bundle size, which is between 1 and 2 kB for most users.
This can make a big difference, especially for client-side validation and serverless environments, by reducing bundle size and speeding up startup time.
Curious to learn more? Check out the publication of my bachelor thesis, where I explain why Valibot can be 10x smaller than Zod.
Who is using Valibot?
We are proud that Valibot is used on sites like The Guardian and that our work adds value to more than 50,000 dependent public GitHub repositories. Our users include many startups and open source projects such as Rolldown and React Router. Chances are you have already run a Valibot schema on your devices without even knowing it.
Valibot has grown from a research paper to a community-driven project with more than 140 contributors and various partners. I want to give a shoutout to Elton, who joined the project as a co-maintainer. He helped rewrite the entire library from scratch and contributed a significant amount to the API reference in our docs. Another shoutout goes to CodingBill, who has become a moderator on Discord. If you have any schema-related questions, he is the guy to talk to!
Below you will find our most influential contributors as well as our current and past sponsors and partners who helped make Valibot v1 possible. If your company uses Valibot and benefits from our work, please consider supporting the project through GitHub sponsors.
What's next on our list?
With Valibot v1, you can rest assured that the library is stable and ready for production. But we are not done yet, we are basically just getting started. On our list are things like a VS Code extension to improve the developer experience, a Zod-to-Valibot codemod to increase adoption, and an OpenAPI package to improve compatibility with other libraries. If you would like to lead or contribute to these efforts, please contact us on Discord!
Just in case this is the first time you hear about Valibot and you have never tried it before, feel free to take a look at our quick start guide and experiment with the library in our online playground.