OpenAPI to TypeScript Generator
Generate TypeScript types and an optional typed fetch client from an OpenAPI 3.0 or 3.1 spec in JSON or YAML, with $ref, allOf and oneOf support.
OpenAPI to TypeScript Generator
Options
3 types generated, 3 endpoints mapped
Generated TypeScript
// Generated TypeScript types from OpenAPI specification
// Pet Store API v1.0.0
export interface Pet {
id: string;
name: string;
species?: "dog" | "cat" | "bird" | "fish";
age?: number;
vaccinated?: boolean;
tags?: string[];
owner?: Owner;
}
export interface Owner {
name: string;
email: string;
phone?: string;
}
export interface CreatePetRequest {
name: string;
species: "dog" | "cat" | "bird" | "fish";
age?: number;
ownerId?: string;
}
Updated . Provided as is. Check the output before you rely on it in production.
How to use OpenAPI to TypeScript Generator
- 1
Paste an OpenAPI 3.x spec
Paste the spec as JSON or YAML, or load the Pet Store sample.
- 2
Choose output options
Generate types only or types plus a typed fetch client, choose union types or TypeScript enums, choose string or Date for date fields, and control optional properties.
- 3
Review the summary
Check how many types were generated and how many endpoints were mapped.
- 4
Copy or download
Copy the generated TypeScript or download it as a single .ts file.
Questions and answers
What OpenAPI versions are supported?
Does it handle $ref references?
Can I generate an API client?
How does it handle oneOf/anyOf?
Can I paste YAML or JSON?
Use it as an API
OpenAPI to TypeScript Generator is also callable as a free HTTP JSON API at
https://aidevhub.io/api/openapi-to-typescript/ — GET with query
parameters or POST with a JSON body, no authentication, CORS enabled, fair use
(abusive traffic is throttled at the edge; there is no per-request quota header). Responses return
{ ok, tool, result, meta }.
curl -s -X POST https://aidevhub.io/api/openapi-to-typescript/ \
-H "Content-Type: application/json" \
-d '{"spec":"{\"openapi\":\"3.0.0\",\"info\":{\"title\":\"API\",\"version\":\"1.0.0\"},\"paths\":{},\"components\":{\"schemas\":{\"User\":{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"integer\"},\"name\":{\"type\":\"string\"}}}}}}"}' Machine-readable contract: /api/tool/openapi-to-typescript.json All API endpoints: /agents/ LLM site index: /llms.txt
For AI agents: how to call this tool
Machine-readable contract, endpoints and examples. Humans can ignore this section.
Best Path For Builders
Dedicated API endpoint
Deterministic outputs, machine-safe contracts, and production-ready examples.
Dedicated API
https://aidevhub.io/api/openapi-to-typescript/ OpenAPI: https://aidevhub.io/api/openapi.yaml