Vyntrise Technologies logoVyntrise Technologies

Which OpenAPI Codegen Should You Choose in 2026? πŸ€” openapi-typescript vs Hey API vs Orval vs Kubb v5 πŸ”₯

November 25, 2026
By nyaomaru
Original Source
Share:

AI Summary

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 πŸ‘‡ {% embed https://dev.to/nyaomaru/which-openapi-codegen-should-you-choose-openapi-typescript-vs-hey-ap...

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 πŸ‘‡

{% embed https://dev.to/nyaomaru/which-openapi-codegen-should-you-choose-openapi-typescript-vs-hey-api-vs-orval-vs-kubb-100p %}

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

LibraryWhy I would choose it
openapi-typescriptTypes with minimal generated code
Hey APIClean SDKs and comfortable DX
OrvalFlexible client, query, and mock generation
Kubb v5Extensible 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) πŸ‘‡

LibraryMay 2026November 2026
openapi-typescript7.13.07.13.0
Hey API0.96.10.99.0
Orval8.8.18.48.0
Kubb4.37.25.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

LibraryTimePeak RSS (max)
openapi-typescript438 ms191 MiB
Hey API527 ms240 MiB
Orval866 ms145 MiB
Kubb337 ms156 MiB

Wait, Kubb?! 😳

Types + Fetch SDK

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

LibraryOld versionCurrent versionReduction
Hey API7,406 ms1,329 ms82.1%
Orval3,457 ms1,723 ms50.2%
Kubb6,236 ms1,155 ms81.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.

LibraryFilesSource size
openapi-typescript11.45 MB
Hey API161.78 MB
Orval1,9262.18 MB
Kubb2,8973.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.

BehaviorHey APIKubb
Result-style HTTP errorsβœ…βœ…
Configurable throwingβœ…βœ…
Status-discriminated resultβ€”βœ…
.unwrap()β€”βœ…
Network failure in nonthrowing modeReturned error in testsRejected 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:

LibraryHTTP 400 in tested query configuration
openapi-react-queryRejects
Hey APIRejects
OrvalResolves by default
KubbRejects 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:

Caseopenapi-typescriptHey APIOrvalKubb
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.

LibraryValidation
openapi-typescriptManual
Hey APIGenerated Zod
OrvalGenerated Zod
KubbGenerated 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

Featureopenapi-typescriptHey APIOrvalKubb
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.

{% embed https://kubb.dev/registry %}

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.

LibraryChanged filesAdded / removed lines
openapi-typescript1+2 / βˆ’2
Hey API3+9 / βˆ’9
Orval3+14 / βˆ’14
Kubb6+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.

{% embed https://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-typescriptHey APIOrvalKubb v5
ApproachTypesSDKConfigurable generatorsExtensible generators
Request styleTyped URLNamed optionsConfigurableNamed options
OutputMinimalCompactConfigurableDistributed
ErrorsResultResult / ThrowStatus / ThrowResult / Throw / Unwrap
ValidationManualGeneratedGeneratedGenerated
ExtensionsScripts / ASTPluginsTransformers / hooksKit / 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! πŸ™ŒπŸ’š