Introduction
Kubb is a meta framework for code generation. It runs a plugin-based pipeline on top of any API specification. An adapter reads your spec. Parsers turn the AST into source files. Plugins generate the output. The pipeline writes, formats, and lints the result, all from a single config file.
The default adapter reads OpenAPI 2.0, 3.0, and 3.1. From there Kubb generates TypeScript types, React Query hooks, Zod validators, MSW mocks, or a custom output. You stop hand-maintaining generated code. The output is deterministic. The same spec always produces the same result.
Features
- Generate TypeScript types, React Query and Vue Query hooks, SWR hooks, Zod validators, Faker mocks, and MSW handlers, each from its own plugin.
- Generate a typed Axios or Fetch client with status-keyed results, auth, validation, file uploads, server-sent events, interceptors, and a swappable transport.
- Read any OpenAPI 2.0, 3.0, or 3.1 spec through the OpenAPI adapter, or add your own adapter.
- Shape the output by grouping files by tag or path, including or excluding operations, and writing to disk, memory, or a custom storage backend.
- Generate Cypress tests and a Model Context Protocol server, or write your own plugin.
- Run generation in Vite, Nuxt, and other bundlers with
unplugin-kubb, or from AI assistants and Claude Code.
Ready for more? Read Installation and Basic Usage, then reach for Configuration, Recipes, and Integrations when you need them.
See it work
Watch the pipeline drain a spec like a work queue. Every schema and operation is its own unit of work: the adapter turns each one into an AST node, and every plugin turns that node into its own file. The run below uses this config:
Expand 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()],
})The architecture guide covers each layer in depth.
Try the same loop yourself. Install Kubb together with the two plugins from that config:
npm install -D kubb@beta @kubb/plugin-ts@beta @kubb/plugin-zod@betaWrite the config above next to your spec and run the generator:
kubb generateKubb writes one file per schema per plugin into ./src/gen. Import a type and the editor knows your API:
import type { Pet } from './gen/types/Pet'
const pet: Pet = { id: 1, name: 'Cat' }That is the full cycle. Change the spec, run kubb generate again, and the types follow.
Community
Join the Discord server, file an issue on GitHub, or sponsor the project on GitHub Sponsors or Open Collective.