OpenAPI to TypeScript

Paste any OpenAPI 3 components/schemas fragment on the left and get TypeScript interfaces on the right. Each named schema becomes its own interface; $ref between schemas resolves locally.

JSON input valid
TypeScript output

      
    

About this conversion

OpenAPI 3 documents describe HTTP APIs in JSON Schema, but the schemas live under components.schemas instead of at the document root. This converter walks that bucket: every named schema becomes its own TypeScript interface (or type alias for primitive / array roots), and $ref between schemas — like Pets referencing Pet via #/components/schemas/Pet — resolves to the matching interface name. Paste a slice of your spec and you get a self-contained TypeScript file you can drop into your client.

The keyword set is the same one the json-schema-to-typescript page handles: type (single or array union), properties, items, required, enum, and local $ref to #/components/schemas, #/definitions, or #/$defs. Schema names are pascal-cased into interface names (pet → Pet, my_user → MyUser) and required carries directly to optional flags. A type: ['string', 'null'] union becomes string | null. enum values become string-literal unions. The output is dependency-free — no codegen runtime, no @apidevtools/swagger-parser install, no project setup.

When to reach for a heavier alternative: if you need an exhaustive Paths × Operations × ResponseStatus type tree (typed fetch wrappers, request body inference per endpoint), use openapi-typescript on npm — that's its job. If you need a generated client SDK with serialization, use openapi-fetch / orval / hey-api. This page is for the narrow case: you have a components.schemas slice (from a doc you read, a vendor API, an MCP server's tool inputs) and you want TypeScript interfaces from it without standing up a code-gen pipeline. The same conversion is also at /api/convert — pass {"schema": "<stringified-snippet>", "mode": "ts"}.

Same shape, other validators

Other JSON shapes