OpenAPI to TypeScript
Generate TypeScript interfaces from an OpenAPI / Swagger spec (JSON or YAML).
components.schemas (OpenAPI 3) or definitions (Swagger 2).OpenAPI to TypeScript turns an OpenAPI or Swagger specification into TypeScript interfaces. Paste your spec as JSON or YAML and it reads every schema under components.schemas (OpenAPI 3) or definitions (Swagger 2), converting each into a named interface with required and optional fields, enums, arrays, and $ref references resolved between them. Because OpenAPI schemas are JSON Schema, the same precise mapping applies.
- ✓OpenAPI 3 and Swagger 2 supported
- ✓Accepts both JSON and YAML input
- ✓Every component schema becomes a named interface
- ✓100% private — nothing is uploaded
What It Converts
The tool focuses on the data models — the object schemas your endpoints send and receive — which are what you need typed in a client. Each schema under components.schemas becomes an interface, and references between them ($ref) resolve to the matching interface name. Since OpenAPI 3.1 aligns with JSON Schema 2020-12, this reuses the same engine as JSON Schema to TypeScript.
OpenAPI 3 vs Swagger 2 Schemas
| OpenAPI 3 | Swagger 2 | |
|---|---|---|
| Schema location | components.schemas | definitions |
| JSON Schema alignment | 3.1 aligns with 2020-12; 3.0 uses an older dialect | Uses Draft 4-like syntax |
| Nullable fields | 3.1: type array ["string","null"]; 3.0: nullable: true | type: string with x-nullable (vendor extension) |
| Detection | Detected automatically from the document shape | Detected automatically from the document shape |
You don't need to tell this tool which version you're using — it looks for components.schemas first and falls back to definitions, so both OpenAPI 3.x and Swagger 2.0 specs convert with the same click.
How to Use It
- 1Paste your full OpenAPI or Swagger document — JSON or YAML both work, and format is detected automatically.
- 2Click Convert — every schema found under components.schemas or definitions becomes its own named TypeScript interface.
- 3$ref pointers between schemas resolve to the matching interface name, so a User schema referencing an Address schema produces address: Address, not a duplicated inline type.
- 4Copy the generated interfaces into your project as the model layer for a hand-written or generated API client.
Common Uses
- ▸Typing an API client — Generate the request and response model interfaces from a provider's OpenAPI spec.
- ▸Contract-first development — Turn your design-first OpenAPI document into the types your frontend and backend share.
- ▸Third-party integrations — Get TypeScript models for an external API you're integrating from its published spec.
- ▸Keeping models in sync — Regenerate interfaces whenever the spec changes so client types never drift from the API.
- ▸Auditing a spec — Convert to TypeScript to quickly spot schemas with vague or missing types before publishing an API.