OpenAPI 3.x to TypeScript types in browser
Convert OpenAPI 3.0.x and 3.1.x specs to TypeScript interfaces. Supports
requestBody, components/schemas, $ref,
anyOf/oneOf, and nullable — zero installation.
OpenAPI 3.x is the current standard for describing REST APIs. It introduced
components/schemas (replacing Swagger 2.0's definitions),
requestBody for typed request payloads, and a richer
content map on responses. OpenAPI 3.1 further aligns with JSON Schema draft 2020-12,
adding support for const, prefixItems, and dropping the non-standard
nullable flag in favour of type: [string, null].
The
OpenAPI to TypeScript browser generator
handles all three subversions (3.0.0 through 3.1.x). It detects the spec version from the
openapi field and applies version-aware parsing — for example, recognising both
nullable: true (3.0.x) and type: ["string", "null"] (3.1) as
producing string | null in the output.
OpenAPI 3.x features in the generated types
- paths interface: every route and method with typed
parameters(path, query, header),requestBody, andresponses - components.schemas interface: all named schemas resolved from
#/components/schemas/refs - $ref resolution: local refs resolved to
components["schemas"]["Name"]TypeScript index access - Composition:
allOf→ intersection (&),anyOf/oneOf→ union (|) - Nullable:
nullable: trueandtype: [T, "null"]both produceT | null
How to use
- Go to OpenAPI to TypeScript Types, paste your OpenAPI 3.x spec (JSON or YAML), and click Generate TypeScript.
- Review the generated types in the preview panel. Schemas map to named interfaces under
components.schemas; path operations map topathsentries. - Download
types.d.tsand import it into your project alongside openapi-fetch or any typed HTTP client.
Related tools
- OpenAPI to TypeScript Types — main generator
- Swagger 2.0 to TypeScript — legacy API support
- OpenAPI to React Query types
- Generate from OpenAPI YAML
- YAML Validator — verify your spec before converting