Skip to main content
The Valibot plugin generates Valibot schemas from your OpenAPI specification. Valibot is a modular and lightweight schema library with excellent bundle size, making it ideal for client-side applications.

Installation

Install the required dependencies:

Configuration

Add the Valibot plugin to your openapi-ts.config.ts:
openapi-ts.config.ts

Schema Generation

Definitions

Generate schemas for reusable component definitions:
Customize definition schema names and casing:
Generated output:
valibot.gen.ts

Requests

Generate validators for API request data (body, query, path, headers):
Generated output:
valibot.gen.ts

Responses

Generate validators for API responses:
Generated output:
valibot.gen.ts

Webhooks

Generate validators for webhook payloads:

Valibot Pipes

Valibot uses a pipe-based architecture for transformations and validations. The plugin generates schemas using Valibot’s pipe syntax:

Metadata Support

Enable Valibot metadata for additional schema information:
Metadata is useful for documentation, code generation, AI structured outputs, and form validation.

Usage Examples

Validating API Requests

Validating API Responses

Async Validation

Type Inference

Form Validation with React

String Formats

Valibot automatically generates appropriate validators for OpenAPI string formats: Example:
Generated schema:

Advanced Configuration

Custom Naming Patterns

Use functions for dynamic naming:

Selective Schema Generation

Disable specific schema categories:

Global Configuration

Bundle Size Benefits

Valibot is designed to be tree-shakable and has a smaller bundle size compared to other validation libraries:
  • Modular architecture: Only import what you need
  • Tree-shakable: Unused validators are removed during bundling
  • Minimal runtime: Core functionality is lightweight
  • Pipe-based composition: Efficient schema composition
Example bundle comparison:

Type Reference

The Valibot plugin exports these configuration types:

Migration from Zod

If you’re migrating from Zod to Valibot:
Key differences:
  • Valibot uses v.pipe() for chaining validators instead of method chaining
  • Valibot uses InferOutput instead of infer
  • Valibot’s parse result uses output instead of data
  • Valibot’s validation issues use a different structure

Validators Overview

Learn about validator plugins and their benefits

Zod Plugin

Alternative validator with method chaining syntax

Valibot Documentation

Official Valibot library documentation