Skip to content

OpenAPI to TypeScript

Generate TypeScript types from the schemas of an OpenAPI 3 or Swagger 2.0 document in YAML or JSON. Every entry under components.schemas, or definitions in Swagger 2.0, becomes an exported interface or type alias, $ref links between them become type names and nullable fields get | null.

Reset

Frequently asked questions

Which parts of the document are converted?

The schemas under components.schemas in OpenAPI 3 and under definitions in Swagger 2.0. Paths, parameters and responses are not turned into types; reference the generated schema types from your own request and response code.

How are schema names turned into type names?

Each schema key is rebuilt in PascalCase, so user-profile becomes UserProfile. When two keys would produce the same name, the second one gets a number appended.

Are nullable fields supported?

Yes. nullable: true from OpenAPI 3.0 and x-nullable: true from Swagger 2.0 add | null, and OpenAPI 3.1 type arrays such as ["string", "null"] become string | null.

What happens to references the tool cannot resolve?

A $ref that points outside the document, or to something other than a schema in components.schemas or definitions, becomes unknown and is listed in a comment at the top of the output.

Is YAML supported?

Yes. Paste the document as YAML or JSON. Anchors and aliases in YAML are expanded before the conversion.

How do I check the document first?

Use the OpenAPI Validator, which lists structural problems and broken references. This converter only reads the schemas and does not report other errors.

About OneClick Pro

OneClick Pro is a free collection of more than 150 web tools for everyday work: converting images and units, formatting and validating code, checking domains and SEO, and working with text, dates and numbers. Every tool runs without registration or subscription, and what you enter is only used to calculate your result and is never stored. Use it as a quick toolbox for one-off tasks, or bookmark the tools you rely on every day.