Skip to content
100% local

OpenAPI to TypeScript types

Turn an OpenAPI or Swagger document into TypeScript interfaces and types.

Input
Output

OpenAPI to TypeScript types

Paste an OpenAPI 3 or Swagger 2 document — JSON or YAML — and this tool generates matching TypeScript interfaces for every schema in components/schemas, plus one type per endpoint for its path and query parameters, request body and responses. It saves the step of hand-writing API types every time a spec changes, and keeps the client in sync with what the server actually returns.

The options control the shape of the output. Choose interface or type declarations, and decide how nullable fields are represented: as an optional property (x?: string) or as a union with null (x: string | null). $ref references can either stay as named types pointing at the matching interface, or be expanded inline wherever they're used. Turn off "generate path, parameter and response types" to get only the component schemas, or turn on a status-code union to see every response code an endpoint can return as a single type. Descriptions from the spec become JSDoc comments above each field, and a name prefix keeps generated types from colliding with your own when you paste them into a larger codebase.

The parser reads standard OpenAPI constructs — object and array schemas, enums, oneOf/anyOf/allOf, nullable, additionalProperties — and follows local $ref pointers within the same document. Endpoints marked deprecated can be skipped entirely, and a document that doesn't look like OpenAPI (no components/schemas or paths section) produces a clear error instead of a blank output.

Everything runs locally in your browser — your API specification, which may describe an unreleased product or an internal system, is never uploaded anywhere. Copy the generated types, download them as a .txt file to paste into a .ts file, or send the output straight back to the input to keep refining it.

FAQ

Does it support both OpenAPI 3 and Swagger 2 documents?
Yes. Both use the same paths structure, and Swagger 2 definitions are read the same way as OpenAPI 3 components/schemas.
What happens to $ref references that point outside the document?
Only local references (starting with #/) are resolved. A $ref to an external file is kept as a named type but can't be expanded, since there is nothing else to read it from.
Can I generate types for just the endpoints, without every component schema?
Component schemas are always generated when present, since request and response types usually reference them. Turn off path types to skip everything derived from paths and keep only the schemas.
Why does a circular schema reference stay as a named type even with "expand" turned on?
A schema that references itself, directly or through another schema, can't be inlined without looping forever, so that one reference falls back to the named type while the rest still expand.
Is my API specification uploaded anywhere?
No. Parsing and type generation run entirely in your browser — your document never leaves your device.