Kubb 5.x · API spec to code 8.3M yearly downloads

Turn your API spec into type-safe code.

Kubb is an open source code generator. Point it at your API spec, such as OpenAPI, and get TypeScript types, API clients, TanStack Query hooks, Zod schemas and MSW mocks, always in sync with your API.
  • Open source, MIT licensed
  • OpenAPI 2.0, 3.0 and 3.1
  • Runs anywhere Node runs
How it works

From spec to code in three steps

Every Kubb run follows the same pipeline, so adding a plugin never changes how the others behave.
01 · Adapt
An adapter parses your spec into one shared AST, so every plugin reads the same model.
02 · Generate
Plugins turn that AST into types, clients, hooks, validators and mocks. Pick the ones your stack needs.
03 · Print
Parsers write the result as TypeScript or Markdown files, with barrel files and formatting handled.
See it in action

From spec to code

Watch how Kubb turns one OpenAPI spec into types, hooks and validators.
petstore.yaml
openapi: 3.0.0
info:
  title: Pet Store API
  version: 1.0.0
paths:
  /pets:
    get:
      operationId: getPets
      summary: List all pets
      parameters:
        - name: limit
          in: query
          schema:
            type: integer
      responses:
        '200':
          description: A list of pets
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Pet'
components:
  schemas:
    Pet:
      type: object
      required:
        - id
        - name
      properties:
        id:
          type: integer
        name:
          type: string
        status:
          type: string
          enum: [available, pending, sold]
Ecosystem

Adapters, plugins and parsers

Mix and match what your stack needs: types, clients, hooks, validators and mocks.
Plugins
14 official plugins for TypeScript, Zod, TanStack Query, MSW and more.
Adapters
1 adapter that reads OpenAPI 2.0, 3.0 and 3.1 into the Kubb AST.
Parsers
2 parsers that print generated code as TypeScript or Markdown.
Downloads

Trusted by developers worldwide

Join thousands of developers using Kubb to generate type-safe code.

Kubb

@kubb/core

npm

8.3M

Total downloads (year)

411.2K+

Weekly

By the numbers

Growing fast

1811+
GitHub stars
101+
Contributors
14+
Official plugins
8.3M
Yearly downloads

Review every generated change in Kubb Studio.

Connect the Kubb CLI or a Docker agent, generate from the browser and diff the output before it reaches your repository. Code stays on machines you control.

Generate your first client in minutes.

Run npx kubb init, point it at your spec and get type-safe code.