Introduction

Generate types, API clients, query hooks, validators, and mocks from API specifications with Kubb.

Kubb generates code from API specifications: TypeScript types, API clients, query hooks, validators, and mocks. Regenerate when your specification changes to keep these files in sync with your API, then import them in your application.

Choose the outputs you need with plugins in one kubb.config.ts file. Generated files belong to your project. The default OpenAPI adapter supports OpenAPI 2.0, 3.0, and 3.1.

Features

See it work

The animation below follows a spec through Kubb's generation pipeline. The adapter turns schemas and operations into AST nodes, then plugins generate files from those nodes.

kubb.config.ts
import { defineConfig } from 'kubb/config'
import { pluginTs } from '@kubb/plugin-ts'
import { pluginZod } from '@kubb/plugin-zod'

export default defineConfig({
  input: './petStore.yaml',
  output: { path: './src/gen' },
  plugins: [pluginTs(), pluginZod()],
})
kubb.config.ts4 in queue
src/genone file per plugin per node
Every schema and operation in the spec is its own unit of work.

See the architecture guide for details about each stage.

Start here

You want toRead
Install Kubb in a projectInstallation
Generate your first clientGenerate your first client
Configure a stack or workflowConfigure generation
Rename files or customize generated codeResolvers, macros, and printers
Run generation during a build or in CIVite, webpack, and CI
Use Kubb with a browser or AI assistantStudio, MCP, and Claude Code
Build a pluginPlugin tutorial
Look up an option or APIConfiguration, commands, and Kit API
Understand the pipelineArchitecture
Upgrade from v4Migration guide

Community

Kubb is free and open source under the MIT license. Get help on Discord, report an issue on GitHub, or read Contributing.