Validation500K+/wkMIT

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
npm install valibot
yarn
yarn add valibot
pnpm
pnpm add valibot

Import

ESM
import * as v from 'valibot';

Quick Example

usage
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

Packagevalibot
CategoryValidation
Weekly Downloads500K+
LicenseMIT
Installnpm install valibot

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.