valibot
Valibot is a modular schema validation library for TypeScript that achieves exceptionally small bundle sizes through a functional, tree-shakeable API design. Wh…
Installation
npm install valibot
yarn add valibot
pnpm add valibot
Import
import * as v from 'valibot';
Quick Example
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>;
const result = v.safeParse(UserSchema, { name: 'Alice', email: '[email protected]' });About valibot
Valibot is a modular schema validation library for TypeScript that achieves exceptionally small bundle sizes through a functional, tree-shakeable API design. While Zod bundles all validation methods into a monolithic schema object, Valibot uses separate function imports for each validation operation, allowing bundlers to eliminate unused validators entirely. A simple string validation might ship only 1-2KB of Valibot code compared to Zod's minimum ~13KB. The API composes validation through pipe(): pipe(string(), minLength(1), email()) creates a validated email string type. Object schemas use object({ name: string(), age: optional(number()) }), and the InferOutput<typeof schema> utility extracts TypeScript types. Valibot supports all standard data types, custom validation through check(), data transformation through transform(), default values, nullable and optional wrappers, union types, and nested object validation. The library provides both parse() (throws on error) and safeParse() (returns result object) validation modes with detailed error paths and messages. Valibot is particularly well-suited for frontend applications and libraries where bundle size is critical. The library aims to provide Zod-level functionality with minimal bundle impact, making it an attractive choice for performance-sensitive projects.
Quick Facts
| Package | valibot |
| Category | Validation |
| Weekly Downloads | 500K+ |
| License | MIT |
| Install | npm install valibot |
Related Packages
Zod is a TypeScript-first schema validation library that provides a concise, chainable API for defin…
Yup is a schema validation library for JavaScript that provides a declarative, chainable API for def…
Ajv (Another JSON Schema Validator) is the fastest JSON Schema validator for JavaScript and TypeScri…
Superstruct is a library for validating data in JavaScript and TypeScript using composable, predicta…
TypeBox is a JSON Schema type builder that creates in-memory JSON Schema objects that can be statica…
Browse npm Packages by Category
Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.