OpenAPI to TypeScript & React Query Hooks Generator
Convert OpenAPI 3.0 & Swagger 2.0 (JSON & YAML) specifications into TypeScript interfaces, typed API clients, and TanStack React Query hooks.
How do I use OpenAPI to TypeScript & React Query Hooks Generator?
Paste your OpenAPI 3.0/3.1 or Swagger 2.0 specification (JSON or YAML) into the left editor, or click 'Load Sample' to load a Petstore spec.
Configure generation flags (`export` keyword, optional `?` properties, `readonly` modifiers, and endpoint path summary comments).
Copy the compiled TypeScript interfaces and enum types directly into your frontend API client.
What features does OpenAPI to TypeScript & React Query Hooks Generator offer?
Supports OpenAPI v3.0 / v3.1 and Swagger 2.0 specs in both JSON and YAML formats
Generates TypeScript interfaces and type aliases for data schemas
Generates type-safe API client fetcher functions with path & query parameter interpolation
Generates TanStack React Query (`useQuery` & `useMutation`) hooks automatically
100% client-side local browser execution — zero data transmission
OpenAPI 3.0 / 3.1 Schema Object to TypeScript AST Mapping
The compiler resolves `components.schemas` (OpenAPI 3.x) and `definitions` (Swagger 2.0), including `$ref` pointers, `allOf`/`oneOf`/`anyOf` compositions, and `nullable` flags.
| OpenAPI 3.x Construct | Schema Definition | Compiled TypeScript Output | Notes |
|---|---|---|---|
| $ref Pointer | $ref: '#/components/schemas/User' | User | Resolves local schema identifier |
| String Enum | type: string, enum: [ACTIVE, PENDING] | 'ACTIVE' | 'PENDING' | Emits strict literal union |
| Composition (oneOf/anyOf) | oneOf: [{ $ref: A }, { $ref: B }] | A | B | Union type expression |
| Composition (allOf) | allOf: [{ $ref: Base }, { type: object }] | Base & { ... } | Intersection type expression |
Frequently Asked Questions about OpenAPI to TypeScript & React Query Hooks Generator
Does this compiler support both OpenAPI 3.x (`components.schemas`) and Swagger 2.0 (`definitions`)?
Yes. The parser automatically detects the specification root (`openapi: 3.x.x` vs `swagger: '2.0'`) and extracts schemas from either `components.schemas` or `definitions`, resolving internal `$ref` pointers accordingly.
How are `required` arrays vs optional properties handled in OpenAPI schemas?
In OpenAPI, object properties are optional by default unless listed in the parent object's `required: [...]` array. The compiler marks any property omitted from `required` with the TypeScript `?` optional modifier.
How does the converter handle `nullable: true` (OpenAPI 3.0) and `type: ['string', 'null']` (OpenAPI 3.1)?
Both OpenAPI 3.0 `nullable: true` attributes and OpenAPI 3.1 JSON Schema type arrays (`['string', 'null']`) are compiled into explicit TypeScript nullable unions (`string | null`).
Can I paste YAML OpenAPI specs as well as JSON?
Yes. The input editor parses both YAML 1.2 and JSON specifications locally in your browser using `js-yaml` before walking the OpenAPI schema tree.
Explore Related Developer Tools
JSON to TypeScript & Zod Schema Generator
Convert JSON objects into typed TypeScript interface definitions or Zod validation schemas instantly.
cURL to Python Requests Converter
Convert cURL commands with Bearer tokens, custom headers, and JSON payloads into clean Python requests code locally in your browser.
cURL to JavaScript Fetch Converter
Transform cURL commands into modern JavaScript and Node.js 20+ Fetch API calls with typed headers and JSON.stringify payloads.
cURL to Axios Request Converter
Convert cURL commands into Axios request config objects (method, url, headers, data) for Node.js and TypeScript projects.
CSV to JSON Converter
Convert CSV spreadsheets and delimited text into structured JSON arrays with auto-delimiter and dynamic data type detection.
JSON to CSV Converter
Convert JSON object arrays into RFC 4180 compliant CSV spreadsheets ready for Excel, Google Sheets, and SQL imports.