Which OpenAPI Codegen Should You Choose in 2026? ๐Ÿค” openapi-typescript vs Hey API vs Orval vs Kubb v5 ๐Ÿ”ฅ

2026-11-26ๆฅๆบ dev.toEnglish
Which OpenAPI Codegen Should You Choose in 2026? ๐Ÿค” openapi-typescript vs Hey API vs Orval vs Kubb v5 ๐Ÿ”ฅ

Hoi hoi!

I'm @nyaomaru, a frontend engineer who loves TypeScript, OSS, and getting lost in forests of generated code. ๐ŸŒณ

Six months ago, I compared four OpenAPI code generators in this article ๐Ÿ‘‡

I chose Hey API.

I'm still using it in production, and I'm pretty happy with it.

But Kubb has changed a lot with v5! ๐Ÿš€

Faster generation? Better clients? A new plugin architecture?

Oh no. Time to go back into the forest. ๐ŸŒณ๐ŸŒณ๐ŸŒณ

Let's see what has changed!

open api test

๐ŸŽฏ TL;DR

Library Why I would choose it
openapi-typescript Types with minimal generated code
Hey API Clean SDKs and comfortable DX
Orval Flexible client, query, and mock generation
Kubb v5 Extensible code generation with much-improved clients

I'm keeping Hey API in my existing projects.

But for my next project? Kubb looks quite tempting. ๐Ÿ‘€

๐Ÿ•ฐ๏ธ Six months later

Here are the versions I tested (Kubb plugins have their own versions) ๐Ÿ‘‡

Library May 2026 November 2026
openapi-typescript 7.13.0 7.13.0
Hey API 0.96.1 0.99.0
Orval 8.8.1 8.48.0
Kubb 4.37.2 5.20.2

Kubb had a major architectural overhaul, while Hey API and Orval continued improving their existing ecosystems.

Let's see what that actually means for us.

๐ŸŽ๏ธ How fast are they now?

For this investigation, I generated a synthetic OpenAPI specification using drf-spectacular.

  • 1,200 operations
  • 484 component schemas
  • 51,878 lines
  • Approximately 1.28 MB

I reran the previous versions using this new specification.

All measurements below are from the same Ryzen 9 7900 machine running WSL2 and Node.js 26. Each result is the median of eight measured executions after one warm-up.

Types only

Generating 484 shared component schemas

Library Time Peak RSS (max)
openapi-typescript 438 ms 191 MiB
Hey API 527 ms 240 MiB
Orval 866 ms 145 MiB
Kubb 337 ms 156 MiB

Wait, Kubb?! ๐Ÿ˜ณ

Types + Fetch SDK

I benchmarked both old and current versions on the same synthetic schema and machine.

Library Old version Current version Reduction
Hey API 7,406 ms 1,329 ms 82.1%
Orval 3,457 ms 1,723 ms 50.2%
Kubb 6,236 ms 1,155 ms 81.5%

That's a massive improvement for both Hey API and Kubb.

openapi-typescript took 751 ms to generate the full operation types, but it uses a generic runtime client rather than generating an SDK for every endpoint, so I've kept it separate.

Generation scopes and output structures still differ, and these aren't measurements against the original production API.

Also, generation isn't everything. A single TypeScript compilation took approximately 2.44 seconds for Hey API and 3.80 seconds for Kubb.

Fast generation doesn't necessarily mean faster everything.

Still, impressive work! ๐Ÿš€

๐ŸŒณ How big is the forest?

Here's the generated output for the full specification.

Library Files Source size
openapi-typescript 1 1.45 MB
Hey API 16 1.78 MB
Orval 1,926 2.18 MB
Kubb 2,897 3.13 MB

A house, a small town, a forest, and a very ambitious forest.

openapi-typescript/ types.ts hey-api/ types.gen.ts sdk.gen.ts client.gen.ts client/ core/ orval/ api.ts schemas/ kubb/ clients/ types/ .kubb/ 

I still prefer Hey API's relatively compact structure.

But Kubb's distributed files aren't necessarily a bad thing. Smaller individual files can make generated code easier to navigate and review.

These are generated source sizes, by the wayโ€”not application bundle sizes.

๐Ÿง‘โ€๐Ÿ’ป Let's actually call an API

Suppose we have three endpoints ๐Ÿ‘‡

GET /users GET /users/{id} POST /users 

openapi-typescript

Using its official companion, openapi-fetch

const client = createClient<paths>({ baseUrl: BASE_URL, }); client.GET("/users", { params: { query: { limit: 2 } }, }); client.GET("/users/{id}", { params: { path: { id: "1" } }, }); client.POST("/users", { body: { id: "1", name: "Ada" }, }); 

No generated function for every endpoint.

Just typed URLs, HTTP methods, and a generic client.

Small. Simple. Useful. ๐Ÿ‘

Hey API

getUsers({ query: { limit: 2 }, }); getUser({ path: { id: "1" }, }); createUser({ body: { id: "1", name: "Ada" }, }); 

This is one of the main reasons I chose Hey API.

I don't need to remember the argument order of 1,200 functions.

Just query, path, and body.

My little brain is happy. ๐Ÿ˜ธ๐Ÿง 

Orval

With useNamedParameters: true

getUsers({ limit: 2 }); getUser({ id: "1" }); createUser({ id: "1", name: "Ada", }); 

Request options can be passed separately, and custom mutators allow you to centralize transport logic. ๐Ÿ‘

Kubb v5

getUsers({ query: { limit: 2 }, }); getUser({ path: { id: "1" }, }); createUser({ body: { id: "1", name: "Ada" }, }); 

This looks familiar. ๐Ÿ‘€

Kubb now gives me the consistent request structure I like in Hey API.

One of my previous concerns is gone. ๐Ÿ˜ธ๐Ÿš€

โš ๏ธ What happens when things explode?

Let's say our API returns

  • 200: User[]
  • 400: { message: string }
  • 409: { conflict: string }

I like result-based error handling, but sometimes I also want exceptions.

More importantly, I want TypeScript to know which error I'm dealing with.

openapi-fetch

const result = await list(); if ( result.response.status === 400 && result.error !== undefined && "message" in result.error ) { console.log(result.error.message); } 

Hey API

const result = await list(); if ( result.response?.status === 400 && result.error !== undefined && "message" in result.error ) { console.log(result.error.message); } 

You get typed error responses, but checking the nested HTTP status alone doesn't narrow the error body.

Orval

const result = await list(); if (result.status === 400) { console.log(result.data.message); } if (result.status === 409) { console.log(result.data.conflict); } 

Nice!

The top-level status acts as a discriminant. ๐Ÿ˜ธ

Kubb v5

const result = await getUsers({ throwOnError: false, }); if (result.status === 400) { if ("message" in result.error) { console.log(result.error.message); } } 

Kubb also provides status-based narrowing. The additional guard handles the possible empty error body. ๐Ÿ‘

To throw or not to throw

  • Hey API
await getUsers({ throwOnError: true, }); 
  • Kubb
await getUsers({ throwOnError: true, }); 

Hey API defaults to result-style HTTP errors in the tested SDK; Kubb defaults to throwing. Both let me choose.

Or, with Kubb

const users = await getUsers({ throwOnError: false, }).unwrap(); 

I particularly like this little .unwrap().

Give me the data or reject. Thank you very much!

There are still differences in what each client considers an error.

Behavior Hey API Kubb
Result-style HTTP errors โœ… โœ…
Configurable throwing โœ… โœ…
Status-discriminated result โ€” โœ…
.unwrap() โ€” โœ…
Network failure in nonthrowing mode Returned error in tests Rejected in tests

Nonthrowing HTTP mode doesn't mean nothing can throw!

๐Ÿช What about TanStack Query?

All four have a way to integrate with TanStack Query.

// openapi-react-query $api.queryOptions("get", "/users"); // Hey API getUsersOptions(); // Orval getGetUsersQueryOptions(); // Kubb getUsersQueryOptions(); 

One interesting difference appeared in the runtime tests:

Library HTTP 400 in tested query configuration
openapi-react-query Rejects
Hey API Rejects
Orval Resolves by default
Kubb Rejects by default

TanStack Query needs a rejected promise to recognize a failed request.

For Orval's tested Fetch configuration, enabling override.fetch.forceSuccessResponse: true changes that behavior.

Not a deal-breaker. Just something worth configuring before your query happily reports that everything is fine while your API is on fire. ๐Ÿ”ฅ

๐Ÿคฏ The enum problem, again

Remember those little enums that caused so much trouble last time?

They're back.

Consider these schema fragments:

BlankEnum: type: string enum: [""] NullEnum: enum: [null] 

Here's what happened:

Case openapi-typescript Hey API Orval Kubb
Empty-string enum (3.0 fixture) โœ… โœ… โœ… โœ…
Null-only enum (3.1 fixture) โœ… โŒ โœ… โœ…

Kubb's previous blank-enum issue is fixed! ๐ŸŽ‰

Its v4 already handled the tested null-only case correctly, so that isn't a new v5 improvement.

Interestingly, Hey API still has a problem with the null-only enum.

type NullEnum = never; 

Oops.

Adding type: 'null' fixes the TypeScript type, but the generated Zod validator can still accept unrelated values.

The verified workaround for this OpenAPI 3.1 case is:

NullEnum: type: "null" 

Now we get the correct type and validator:

type NullEnum = null; const zNullEnum = z.null(); 

There's also an existing upstream issue.

It's a specific edge case, not a general problem with nullable properties.
But this is why I test generated types instead of simply trusting them.

๐Ÿ›ก๏ธ Type safety at runtime

TypeScript is wonderful. Unfortunately, my backend doesn't care. ๐Ÿ˜น

All four default clients accepted invalid response data in my tests. With runtime validation, all four rejected it.

Library Validation
openapi-typescript Manual
Hey API Generated Zod
Orval Generated Zod
Kubb Generated Zod

Encoding and decoding

Kubb has another interesting feature: directional transformations.

const result = await postTimestamp({ body: { at: new Date() }, }); const date: Date = result.data.at; 

With inferred: 'codec' and a custom datetime printer, Kubb generated the ISO string โ†” Date transformations and integrated them into the client.

These are directional Zod transforms, not native bidirectional z.codec objects.

Less glue code. Happy cats. ๐Ÿˆ

Server-Sent Events

Both Hey API and Kubb handled typed SSE in my tests.

// Hey API const { stream } = await heyEvents(); for await (const event of stream) { console.log(event.value); } 
// Kubb const { stream } = await kubbEvents(); for await (const event of stream) { console.log(event.data.value); } 

Different wrappers, same typed streaming goodness.

๐Ÿงฐ The ecosystem

Feature openapi-typescript Hey API Orval Kubb
Fetch โœ… โœ… โœ… โœ…
Axios โ€” โœ… โœ… โœ…
React Query โœ… โœ… โœ… โœ…
SWR โ€” โœ… โœ… โœ…
Zod generation โ€” โœ… โœ… โœ…
Faker / MSW โ€” โœ… โœ… โœ…
Native custom plugins โ€” โœ… โ€” โœ…

These are official integrations and companions, not necessarily built-in features. Other extension mechanisms exist.

One correction from my previous comparison: Hey API also supports Faker, MSW, and SWR. I verified Faker/MSW behavior and SWR generation.

The ecosystems are getting crowded. In a good way! ๐Ÿ˜ธ

๐Ÿ—๏ธ Kubb v5: More than an OpenAPI generator?

This is where Kubb gets interesting.

OpenAPI โ†“ Unified AST โ†“ Plugins + Resolvers + Macros โ†“ Generated code 

Kubb v5 lets plugins share a normalized AST instead of independently parsing the specification.

But what does that actually give us?

Resolvers

Let's say my project requires an Api prefix and .model.ts filenames.

import { pluginTs, resolverTs } from '@kubb/plugin-ts'; pluginTs({ resolver: { name(name) { return `Api${resolverTs.name(name)}`; }, file: { baseName({ name, extname }) { return `${name}.model${extname}`; }, }, }, }); 

The result?

- GetUsersOptions + ApiGetUsersOptions 

Even better, the Fetch plugin automatically imports the renamed type from the renamed file.

No regex magic. No broken imports. Strict TypeScript compilation passed.

Macros

I also tested removing descriptions from TypeScript output while preserving them in Zod output.

It worked. Each plugin can transform its own AST without affecting the others.

Kubb Kit and Registry

Kubb Kit lets developers build custom generators using the same infrastructure as official plugins.

And the Kubb Registry lets the community distribute extensions.

Kubb registry ยท Kubb

The list of Kubb extensions that the Kubb CLI, Kubb Studio and kubb.dev read. It is a set of static JSON documents under one base URL.

favicon kubb.dev

Hey API also supports custom plugins, so extensibility isn't unique to Kubb.

But the combination of shared AST, resolvers, macros, and Kit makes Kubb particularly interesting for building a company-wide generation platform.

๐Ÿค– AI can grow a forest overnight

AI makes generating code faster. Keeping it consistent? Not so much.

Imagine five AI agents building five features, each inventing different API wrappers and error handling.

Congratulations! Five different forests. ๐ŸŒณ๐ŸŒด๐ŸŒฒ๐ŸŽ‹๐ŸŒต

Why keep telling AI the same rules when we can encode them into a shared generator?

Let AI help build the plugins. Let deterministic codegen enforce the conventions.

One shared plugin can serve ten projects instead of ten AI agents reinventing the same thing.

Maybe the best use of AI isn't generating more code. It's building better tools that generate code for us.

And that's exactly why Kubb's architecture caught my attention.

๐ŸŒฑ Maintaining the forest

I also tested how generated code changes when the API evolves.

Library Changed files Added / removed lines
openapi-typescript 1 +2 / โˆ’2
Hey API 3 +9 / โˆ’9
Orval 3 +14 / โˆ’14
Kubb 6 +59 / โˆ’59

These results are from renaming one operationId.

All four generated identical output with unchanged input, and breaking schema changes were caught by application type checks.

More files aren't necessarily worse. Just keep your forest under control! ๐ŸŒณ

๐Ÿค Kubb Studio

Kubb also introduced Kubb Studio, a separate collaboration service.

Kubb Studio ยท Generate typed clients from your API spec

Generate TypeScript clients, TanStack Query hooks and Zod schemas from your API spec on your own machines. Review every change, then ship from CI. Start free.

favicon kubb.studio

It offers UI-based plugin configuration, generated-file comments, and npm snapshots through GitHub Actions.

That could help frontend teams work against upcoming backend contracts before release.

I haven't tested it hands-on yet, but it's an interesting direction!

๐Ÿ““ Side by side

openapi-typescript Hey API Orval Kubb v5
Approach Types SDK Configurable generators Extensible generators
Request style Typed URL Named options Configurable Named options
Output Minimal Compact Configurable Distributed
Errors Result Result / Throw Status / Throw Result / Throw / Unwrap
Validation Manual Generated Generated Generated
Extensions Scripts / AST Plugins Transformers / hooks Kit / Resolvers / Macros

๐Ÿš€ Back out of the forest

Six months ago, I chose Hey API. And I'm keeping it.

But Kubb v5 surprised me.

It's faster, its clients have improved, and its architecture offers something beyond a ready-made SDK.

In the AI era, I think shared development foundations matter more than ever.

For my next large frontend project, I'd love to give Kubb a try.

Six months ago, I wanted a smaller forest.

Now, I want to design how it grows.

Before AI plants another million trees. ๐ŸŒณ๐Ÿค–

Thanks for reading! ๐Ÿ™Œ๐Ÿ’š

ๅŽŸๆ–‡๏ผšhttps://www.a8q9.cn/en/article/which-openapi-codegen-should-you-choose-in-2026-openapi-typescript-vs-hey-api-vs-0e9f0e.html

็›ธๅ…ณๆ–‡็ซ