plugins: [pluginValibot()]OpenAPI to Valibot schema generator
@kubb/plugin-valibot
Generates Valibot v1 schemas from your OpenAPI spec so you validate API responses, form input, and query params at runtime.
- GitHub stars12kubb-labs/plugins
- Unpacked size565.7kBv0.1.0 on npm
- Latest release11m agov0.1.0 · Nov 18, 2026
The Valibot plugin generates a Valibot v1 schema for every schema in your OpenAPI spec, plus the parameter, request, and response schemas of each operation.
Every generated schema is a Standard Schema, so any library that takes one can validate with it.
@kubb/plugin-fetch, @kubb/plugin-axios, and @kubb/plugin-client validate with these schemas when you set their validator option to 'valibot'.
Installation
kubb add plugin-valibotbun add -d @kubb/plugin-valibotpnpm add -D @kubb/plugin-valibotnpm install --save-dev @kubb/plugin-valibotyarn add -D @kubb/plugin-valibotkubb add installs the version the Kubb registry pins and adds pluginValibot() to kubb.config.ts. It needs a kubb.config.ts, so run kubb init first in a new project.
Setup
- No other plugins are needed.
- Install
valibot1.2 or later in the app that uses the generated code.
Options worth knowing
| Option | Default | What it does |
|---|---|---|
inferred | false | Adds a type next to each schema, so you can skip @kubb/plugin-ts. |
coercion | false | Converts input before validation, such as query strings. |
typeGuards | false | Adds is* type guards and assert* assertions. |
printer | None | Replaces the Valibot call for a schema type. |
Example
This config generates the schemas with a v.InferOutput type next to each one. For a Pet schema, the plugin writes petSchema.ts:
import { defineConfig } from 'kubb/config'
import { pluginValibot } from '@kubb/plugin-valibot'
export default defineConfig({
input: './petStore.yaml',
output: { path: './src/gen' },
plugins: [pluginValibot({ inferred: true })],
})import * as v from 'valibot'
export const petSchema = v.object({
id: v.pipe(v.number(), v.integer()),
name: v.string(),
status: v.optional(v.string()),
tags: v.optional(v.array(v.string())),
})
export type PetSchemaType = v.InferOutput<typeof petSchema>Guides
- Valibot schemas for OpenAPI formats
- Infer TypeScript types from Valibot schemas
- Coerce input with Valibot
- Customize generated schemas
Differences from the Zod plugin
The two plugins share option names, generated names, and file layout. These Zod options have no Valibot counterpart:
| Zod option | In this plugin |
|---|---|
guidType | Not needed. v.uuid() checks the shape only, so it already accepts any GUID. |
inferred: 'codec' | Always on. A request schema gets v.InferInput and every other schema v.InferOutput. |
compile and mini | Zod features. Valibot is modular by default. |
Dependencies
No extension dependencies.
