openapi-typescript-codegen is an MIT-licensed Node.js library that generates TypeScript or JavaScript API clients from an OpenAPI specification, and it is aimed at frontend and full-stack teams that want typed clients generated inside their own build pipeline rather than through a Java-based code generator.
What it is
openapi-typescript-codegen is a Node.js command-line tool and library that reads an OpenAPI specification and emits a typed API client. It accepts OpenAPI v2.0 and v3.0 documents in either JSON or YAML, and it can target five HTTP clients: fetch, xhr, node, axios and angular. The generated output is plain TypeScript that compiles with tsc or with @babel/plugin-transform-typescript, so it drops into an existing frontend toolchain without a separate build step. The project lives in the Node.js and npm ecosystem, is framework-agnostic by design, and exposes the same generator through a CLI, a Node.js API and npx.
The concrete problem it solves is stated plainly in the README's own rationale: frontend teams like OpenAPI, but do not want to run Java codegen in their builds. Teams that want a typed client would otherwise either hand-write one and keep it in sync with the spec by hand, or adopt a heavier Java-based OpenAPI generator with its own runtime and build requirements. This project replaces both positions with a lightweight npm dev dependency that produces a client in one command, and it adds practical options such as aborting requests through the cancelable promise pattern and resolving external references using json-schema-ref-parser.
Key capabilities
- Generates a client for one of five HTTP targets selected with
--client [fetch, xhr, node, axios, angular], defaulting to fetch.
- Reads OpenAPI specification v2.0 and v3.0, supplied as JSON or YAML, from a path, a URL or literal string content via
--input.
- Splits output into controllable artifacts with
--exportCore, --exportServices, --exportModels and --exportSchemas.
- Shapes the generated surface with
--useOptions, --useUnionTypes, custom --name, --postfixServices and --postfixModels.
- Supports
--indent options of 4, 2 or tab, and accepts a --request path to a custom request file.
- Runs through three entry points: the
openapi CLI, a Node.js API, and npx.
- Resolves external references through json-schema-ref-parser, and supports request aborting via the cancelable promise pattern.
Who uses it and how
- Frontend teams whose build pipelines already run Node.js and who want generated clients produced as part of those builds rather than in a separate Java toolchain.
- Angular shops, which the topic list and the
angular client target both point to, alongside axios, fetch, node and xhr users.
- Teams consuming a specification published at a URL, since
--input accepts a URL as well as a local path.
- Projects that generate a client once and commit the output, then regenerate when the spec changes, using
--exportSchemas or --useUnionTypes to control the emitted shape.
- Builds that mix TypeScript and JavaScript, since output compiles under tsc and under @babel/plugin-transform-typescript.
Getting started
Install as a dev dependency with npm install openapi-typescript-codegen --save-dev, then generate a client with openapi --input ./spec.json --output ./generated, adding --client xhr or another target if fetch is not wanted. The same generator is available through the Node.js API and through npx.
How it compares
The README names one direct successor, @hey-api/openapi-ts, which began as a fork of this project with the goal of resolving its most pressing issues and which now plans to carry the OpenAPI generator forward. Where openapi-typescript-codegen is the original implementation the author has since stepped back from, @hey-api/openapi-ts is the actively maintained continuation, and the README points readers to a dedicated migration page at heyapi.dev. Both address the same job — typed clients from an OpenAPI specification inside a Node.js build — so the choice is primarily about maintenance status rather than capability.
When to use it — and when not
The honest limitation is stated at the top of the README: the author reports that time limitations have left the project unmaintained for a while, all open pull requests and issues were scheduled for archival on 1 May 2024, and all versions of the package were to be deprecated in npm. The repository carries 213 open issues, and new projects should follow the migration guidance to @hey-api/openapi-ts rather than starting here.
Existing projects may still run it, since it is a development-time dependency with no database, object storage or SMTP service to operate — installing the package and running the openapi command is the entire operational surface. The reason to migrate is the deprecation path and the stalled issue queue, not runtime complexity.
project readme (upstream, from github) — read inline
Important announcement
[!IMPORTANT]
Please migrate your projects to use @hey-api/openapi-ts
Due to time limitations on my end, this project has been unmaintained for a while now. The @hey-api/openapi-ts
project started as a fork with the goal to resolve the most pressing issues. going forward they are planning to
maintain the OpenAPI generator and give it the love it deserves. Please support them with their work and make
sure to migrate your projects: https://heyapi.dev/openapi-ts/migrating.html#openapi-typescript-codegen
- All open PR's and issues will be archived on the 1st of May 2024
- All versions of this package will be deprecated in NPM
👋 Thanks for all the support, downloads and love! Cheers Ferdi.
OpenAPI Typescript Codegen

Node.js library that generates Typescript clients based on the OpenAPI specification.
Why?
- Frontend ❤️ OpenAPI, but we do not want to use JAVA codegen in our builds
- Quick, lightweight, robust and framework-agnostic 🚀
- Supports generation of TypeScript clients
- Supports generations of Fetch, Node-Fetch, Axios, Angular and XHR http clients
- Supports OpenAPI specification v2.0 and v3.0
- Supports JSON and YAML files for input
- Supports generation through CLI, Node.js and NPX
- Supports tsc and @babel/plugin-transform-typescript
- Supports aborting of requests (cancelable promise pattern)
- Supports external references using json-schema-ref-parser
Install
npm install openapi-typescript-codegen --save-dev
Usage
$ openapi --help
Usage: openapi [options]
Options:
-V, --version output the version number
-i, --input <value> OpenAPI specification, can be a path, url or string content (required)
-o, --output <value> Output directory (required)
-c, --client <value> HTTP client to generate [fetch, xhr, node, axios, angular] (default: "fetch")
--name <value> Custom client class name
--useOptions Use options instead of arguments
--useUnionTypes Use union types instead of enums
--exportCore <value> Write core files to disk (default: true)
--exportServices <value> Write services to disk (default: true)
--exportModels <value> Write models to disk (default: true)
--exportSchemas <value> Write schemas to disk (default: false)
--indent <value> Indentation options [4, 2, tab] (default: "4")
--postfixServices Service name postfix (default: "Service")
--postfixModels Model name postfix
--request <value> Path to custom request file
-h, --help display help for command
Examples
$ openapi --input ./spec.json --output ./generated
$ openapi --input ./spec.json --output ./generated --client xhr
Documentation
The main documentation can be found in the openapi-typescript-codegen/wiki
Sponsors
If you or your company use the OpenAPI Typescript Codegen, please consider supporting me. By sponsoring I can free up time to give this project some love! Details can be found here: https://github.com/sponsors/ferdikoomen