Introduction
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
- Generate TypeScript types, typed Axios or Fetch clients, React Query, Vue Query, and SWR hooks.
- Validate data with Zod, create Faker data and MSW handlers, generate Cypress tests, or expose your API through a generated MCP server.
- Customize the pipeline with adapters, plugins, parsers, macros, and resolvers, or write output to disk, memory, or a custom storage backend.
- Run generation with Vite and webpack, other bundlers, or in CI. Connect AI tools through MCP or use the Claude Code integration.
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.
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()],
})
See the architecture guide for details about each stage.
Start here
| You want to | Read |
|---|---|
| Install Kubb in a project | Installation |
| Generate your first client | Generate your first client |
| Configure a stack or workflow | Configure generation |
| Rename files or customize generated code | Resolvers, macros, and printers |
| Run generation during a build or in CI | Vite, webpack, and CI |
| Use Kubb with a browser or AI assistant | Studio, MCP, and Claude Code |
| Build a plugin | Plugin tutorial |
| Look up an option or API | Configuration, commands, and Kit API |
| Understand the pipeline | Architecture |
| Upgrade from v4 | Migration guide |
Community
Kubb is free and open source under the MIT license. Get help on Discord, report an issue on GitHub, or read Contributing.