OpenAPI to TypeScript

Generate TypeScript interfaces from an OpenAPI / Swagger spec (JSON or YAML).

Reads 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 3Swagger 2
Schema locationcomponents.schemasdefinitions
JSON Schema alignment3.1 aligns with 2020-12; 3.0 uses an older dialectUses Draft 4-like syntax
Nullable fields3.1: type array ["string","null"]; 3.0: nullable: truetype: string with x-nullable (vendor extension)
DetectionDetected automatically from the document shapeDetected 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

  1. 1Paste your full OpenAPI or Swagger document — JSON or YAML both work, and format is detected automatically.
  2. 2Click Convert — every schema found under components.schemas or definitions becomes its own named TypeScript interface.
  3. 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.
  4. 4Copy the generated interfaces into your project as the model layer for a hand-written or generated API client.

Common Uses

  • Typing an API clientGenerate the request and response model interfaces from a provider's OpenAPI spec.
  • Contract-first developmentTurn your design-first OpenAPI document into the types your frontend and backend share.
  • Third-party integrationsGet TypeScript models for an external API you're integrating from its published spec.
  • Keeping models in syncRegenerate interfaces whenever the spec changes so client types never drift from the API.
  • Auditing a specConvert to TypeScript to quickly spot schemas with vague or missing types before publishing an API.

Frequently Asked Questions

Both. OpenAPI specs are commonly written in YAML, so the tool parses YAML and JSON transparently and generates the same TypeScript.

The schemas under components.schemas (OpenAPI 3) or definitions (Swagger 2) — your data models. References between schemas are resolved to named interfaces.

It generates the model interfaces, which are the reusable part you need typed. Endpoint function generation is a heavier, framework-specific task best handled by a dedicated client generator.

No. Parsing and conversion run entirely in your browser. Nothing is sent to a server.

Yes — if you've generated a spec with the HAR to OpenAPI tool from captured network traffic, paste that output here to get typed models from it.

The tool reports that no schemas were found rather than failing silently, so you know to check the spec structure — some minimal specs only inline schemas directly on operations rather than defining reusable components.

Related Tools