plugins: [pluginTs()]TypeScript
@kubb/plugin-ts
Generates TypeScript types and interfaces from your OpenAPI spec, the typed foundation the other Kubb plugins build on.
- Downloads1.3M/ monthnpm, last 30 days
- GitHub stars8kubb-labs/plugins
- Unpacked size625.8kBv5.0.10 on npm
- Latest release9h agov5.0.10 · Oct 13, 2026
The TypeScript plugin generates a type or interface for every schema in your OpenAPI spec, plus the request, response, and parameter types of each operation.
Kubb runs this plugin before the plugins that import its types, whatever the order of the plugins array.
Installation
bun add -d @kubb/plugin-tspnpm add -D @kubb/plugin-tsnpm install --save-dev @kubb/plugin-tsyarn add -D @kubb/plugin-tsOr run kubb add plugin-ts to install the version the Kubb registry pins and add pluginTs() to kubb.config.ts.
Setup
No other plugins or packages are needed.
Options worth knowing
enum.typesets how enums are written:asConst(default),enum,constEnum,literal, orinlineLiteral.enum.constCasing,enum.typeSuffix, andenum.keyCasingtune the names.syntaxTypewrites object schemas astypealiases (default) orinterfacedeclarations.optionalTypesets how optional properties are written:questionToken(default),undefined, orquestionTokenAndUndefined.arrayTypewrites arrays asT[](default) orArray<T>.groupsplits the output into folders by tag or path. It does not work withoutput.mode: 'file'.
With the default OpenAPI adapter, int64 fields are typed as bigint, while JSON responses hold numbers. Set integerType: 'number' on adapterOas for most JSON APIs.
See Options for every option and its default.
Example
The config below generates the types into src/gen/types.
import { defineConfig } from 'kubb/config'
import { pluginTs } from '@kubb/plugin-ts'
export default defineConfig({
input: './petStore.yaml',
output: { path: './src/gen' },
plugins: [
pluginTs(),
],
})Dependencies
No extension dependencies.
Used by
Extensions that list TypeScript as a dependency.