plugins: [pluginZod()]Zod
@kubb/plugin-zod
Generates Zod v4 schemas from your OpenAPI spec so you validate API responses, form input, and query params at runtime.
- Downloads923.8K/ monthnpm, last 30 days
- GitHub stars8kubb-labs/plugins
- Unpacked size586.3kBv5.4.7 on npm
- Latest release43m agov5.4.7 · Oct 13, 2026
Generates Zod v4 schemas from your OpenAPI spec. Use them to validate API responses, form input, and query params at runtime.
The schemas can stand on their own. With inferred: true, the plugin also exports a z.infer type next to each schema, so you can skip @kubb/plugin-ts. Client plugins such as @kubb/plugin-fetch and @kubb/plugin-axios use these schemas when you set their validator option.
Installation
bun add -d @kubb/plugin-zodpnpm add -D @kubb/plugin-zodnpm install --save-dev @kubb/plugin-zodyarn add -D @kubb/plugin-zodOr run kubb add plugin-zod to install the version the Kubb registry pins and add pluginZod() to kubb.config.ts.
Setup
Install Zod v4 or higher in the app that uses the generated code. No other plugins are needed.
Options worth knowing
minigenerates Zod Mini schemas for smaller bundles, and switchesimportPathtozod/mini.importPathsets the module the files importzfrom. The default iszod.inferredexports az.infertype alias next to each schema.coercionwraps schemas inz.coerce, so input is converted before validation. Pass an object to coerce only dates, strings, or numbers.guidTypepicksz.uuid()(default) orz.guid()forformat: uuid.regexTypewrites apatternas a regex literal (default) or aRegExpconstructor.typeGuardsaddsis*type guards andassert*assertions.compilewraps schemas inz.compilefor faster validation.
Dependencies
No extension dependencies.