OpenAPI to TypeScript
Generate TypeScript interfaces from an OpenAPI spec online — components.schemas become typed interfaces with $ref resolution and nullable unions. Free, runs in your browser.
About OpenAPI to TypeScript
Paste an OpenAPI 3.x or Swagger 2.0 document and get TypeScript interfaces for every schema in components.schemas (or definitions). Cross-$refs resolve to named interfaces, allOf merges, enums become literal unions, and OpenAPI nullable: true becomes a | null union.
The generated file starts with a comment listing every endpoint and operationId, so it doubles as a quick API overview. It pairs well with fetch-based clients — name the interfaces and import them into your API layer.
Type generation is structural: formats like date-time stay string unless the schema says otherwise, and unsupported keywords degrade to any with a warning rather than failing. Everything runs locally.
How to use OpenAPI to TypeScript
- Paste or upload your OpenAPI document (JSON or YAML).
- Review the generated interfaces — warnings list anything approximated (unresolvable external refs, unsupported keywords).
- Copy the output or download api-types.ts.
Frequently asked questions
Does it generate a full client (like openapi-typescript)?
It generates the schema interfaces plus an endpoint comment index — the part most handwritten clients actually need. Full paths/responses type maps require runtime libraries and are out of scope.
How are $refs handled?
Local refs (#/components/schemas/…) resolve to named interfaces, including recursive schemas. External refs (other files/URLs) can't be fetched and are emitted as any with a warning.
Does nullable: true work?
Yes — OpenAPI 3.0's nullable flag is normalized to a type union with null before generation, so string nullable fields come out as string | null.
Is the spec uploaded?
No — parsing and generation happen entirely in your browser.