What is Valibot?
Valibot is an open source schema library for TypeScript that prioritizes bundle size optimization, type safety, and developer experience. It enables developers to create schemas that describe structured data sets, similar to TypeScript type definitions but with the added capability of runtime execution to validate unknown data.
The library features a modular API design that allows bundlers to remove unused code through tree shaking and code splitting, resulting in minimal bundle sizes starting at less than 700 bytes. It supports a wide range of TypeScript types, from primitive values to complex objects, and includes built-in validation and transformation helpers for comprehensive data handling.
Features
- Fully type safe: Enjoy the benefits of type safety and static type inference in TypeScript
- Small bundle size: Due to the modular design of our API the bundle size starts at less than 700 bytes
- Validate everything: Supports almost any TypeScript type from primitive values to complex objects
- 100% test coverage: Valibot's source code is open source and fully tested with 100% coverage
- Helpers included: Important validation and transformation helpers are already included
- API with great DX: Minimal, readable and well thought out API for a great developer experience
Use Cases
- Client-side validation of forms in web applications
- Serverless environment data validation
- Runtime type safety for unknown data in TypeScript projects
- Data structuring and validation in APIs
- Reducing bundle size in front-end applications through modular imports
FAQs
-
Where can I enter my credit card?
You don't have to! Valibot is available free of charge and licensed under the MIT License. However, we rely on partners and sponsors to fund the project. If your company would like to support us, you can take a look at our sponsor page on GitHub. -
What exactly does Valibot do?
The core function of Valibot is to create a schema that describes a structured data set. A schema can be compared to a type definition in TypeScript. The big difference is that TypeScript types are 'not executed' and are more or less a DX feature. A schema on the other hand, apart from the inferred type definition, can also be executed at runtime to guarantee type safety of unknown data. -
How does a modular design reduce bundle size?
Due to the modular design of our API, a bundler can use the import statements to remove the code you don't need. This way, only the code that is actually used ends up in your production build. This also allows us to add new functionality to Valibot without increasing the size for all users. -
How is it different from Zod?
The functionality of Valibot is very similar to Zod. The biggest difference is the modular design of our API and the ability to reduce the bundle size to a minimum through tree shaking and code splitting. Depending on the schema, Valibot can reduce the bundle size up to 95% compared to Zod. Especially for client-side validation of forms and serverless environments this can be a big advantage.
Related Queries
Helpful for people in the following professions
Valibot Uptime Monitor
Average Uptime
100%
Average Response Time
255.97 ms