OpenAPI to TypeScript Converter Online — Generate TS Types & Interfaces

OpenAPI to TypeScript Converter

Convert OpenAPI/Swagger specs (JSON or YAML) to TypeScript interfaces, types, or Zod schemas.

Free online OpenAPI to TypeScript converter. Paste any OpenAPI 3.0/3.1 or Swagger 2.0 specification in JSON or YAML format and generate clean, fully-typed TypeScript interfaces, type aliases, or Zod validation schemas. Supports resolved $ref models, allOf/oneOf/anyOf union and intersection types, string enums, optional fields, JSDoc annotations, and endpoint path request/response types. Runs server-side with zero data storage.

Keywords: openapi to typescript, swagger to typescript, openapi to ts, swagger to ts interfaces, openapi typescript generator, convert swagger to typescript, openapi to zod, openapi typescript types, swagger type generator, openapi 3 to typescript, swagger 2 to typescript, generate typescript from openapi

Tags: openapi, swagger, typescript, types, interfaces, zod, converter, generator, api

Browse all 38 Developer Tools tools →

How to OpenAPI to TypeScript Converter Online

  1. Paste your OpenAPI 3.0, OpenAPI 3.1, or Swagger 2.0 specification in JSON or YAML format into the input editor on the left.

  2. Choose your preferred output mode: TypeScript Interfaces (declaration merging), Type Aliases (unions/primitives), or Zod runtime validation schemas.

  3. Configure type options including custom type prefix (e.g., Api or Dto), readonly properties, and export statements to match your coding standards.

  4. Toggle "JSDoc" to retain OpenAPI schema descriptions, parameter notes, and summary documentation as native TypeScript docstrings.

  5. Toggle "Path Types" to generate comprehensive request parameter interfaces, request body types, and response types for every REST endpoint.

  6. Click "Convert" or press ⌘↵ (Mac) / Ctrl+Enter (Windows) to instantly execute the type generation engine.

  7. Copy individual types or the entire generated TypeScript code, or click "Download" to save the file as types.ts or schema.ts.

OpenAPI to TypeScript Converter Features

  • Full specification compatibility: Seamlessly parses OpenAPI 3.0, OpenAPI 3.1, and Swagger 2.0 definitions.

  • Dual-format support: Automatically detects and parses JSON and YAML API schemas without manual configuration.

  • Three dedicated output targets: Generate TypeScript interfaces, TypeScript type aliases, or Zod schemas with inferred static types.

  • Complete $ref pointer dereferencing: Resolves nested, sibling, and circular internal reference pointers across components and definitions.

  • Advanced schema composition: Correctly models allOf (intersections/inheritance), oneOf (discriminated unions), and anyOf structures.

  • Rich JSDoc preservation: Converts OpenAPI descriptions and summary attributes into native JSDoc comments on types and properties.

  • Path & operation typing: Generates typed parameters (path, query, header), request payload types, and HTTP status code response types.

  • Enum & literal conversion: Converts OpenAPI string/number enums into type-safe string literal unions or typed constants.

  • Custom type prefixing: Prepend prefixes like "Api", "Dto", or "I" across all generated models to avoid collisions with local interfaces.

  • Immutability options: Add the readonly modifier to all generated interface properties for immutability-first architectures.

  • Runtime validation with Zod: Output includes Zod schemas with string format validations (email, uuid, url) and number constraints (min, max).

  • Private and secure: Spec conversion executes entirely in-memory with zero retention or external network logging.

  • Developer ergonomics: Full keyboard shortcut support (⌘↵ to convert, ⌘⇧C to copy, ⌘⇧K to clear).

Supported SQL Dialects

The OpenAPI to TypeScript Converter supports 4 SQL dialects. Select the right dialect for accurate formatting and keyword recognition.

OpenAPI 3.1 (Modern Standard)
Full JSON Schema 2020-12 alignment, type arrays including null, dynamic Webhook definitions, and pattern properties.
OpenAPI 3.0 (Widespread Industry Standard)
Components object with schemas, securitySchemes, requestBodies, parameters, and nullable property support.
Swagger 2.0 (Legacy Specification)
Definitions object, host/basePath routing, body and formData parameters, and Swagger security definitions.
Zod Validation Schemas
Generates runtime validation schemas using Zod with string format helpers (email, url, uuid), min/max limits, and infer<T> typings.

Frequently Asked Questions

What is an OpenAPI to TypeScript converter?
An OpenAPI to TypeScript converter is a developer utility that automatically transforms an OpenAPI (formerly Swagger) REST API specification into strongly-typed TypeScript definitions. Instead of manually writing and maintaining interfaces or types that mirror backend APIs, this tool parses your API specification (JSON or YAML) and emits type-safe TypeScript interfaces, type aliases, or Zod validation schemas.
What is the difference between Interfaces, Type Aliases, and Zod output modes?
Interfaces mode produces standard TypeScript "interface" declarations, which support declaration merging and are standard for object-oriented architectures. Types mode outputs "type" aliases, providing more flexibility for unions, intersections, and primitive type mappings. Zod mode outputs runtime schema validators using the Zod library alongside inferred static TypeScript types (e.g. "type User = z.infer<typeof UserSchema>"), enabling both compile-time type safety and runtime payload validation.
Does this converter support both JSON and YAML OpenAPI specs?
Yes. The parser automatically detects whether your specification is formatted in JSON or YAML. You can paste raw JSON, formatted YAML, or Swagger 2.0/OpenAPI 3.x documents interchangeably.
How are OpenAPI $ref references resolved?
The converter dereferences all internal JSON pointers (such as "#/components/schemas/Pet" or "#/definitions/User") before generating code. This ensures that nested models, inherited properties, and referenced schemas produce accurate, self-contained TypeScript declarations.
What does the "Path Types" option generate?
When "Path Types" is enabled, the tool inspects the "paths" section of your specification and generates dedicated types for every HTTP endpoint. This includes query/path parameter interfaces (e.g., ListUsersParams), JSON request body payload types (e.g., CreateUserRequestBody), and response types mapped by HTTP status code (e.g., GetUserResponse200, GetUserResponse404).
How are OpenAPI composition keywords (allOf, oneOf, anyOf) handled?
allOf schemas are converted into TypeScript intersection types (&) or interface extensions (extends) that combine multiple object schemas. oneOf and anyOf schemas are converted into TypeScript union types (|), accurately representing polymorphic payloads and discriminated unions.
Can I use the generated types with fetch, Axios, or TanStack Query?
Yes. The generated TypeScript interfaces and type aliases are standard TypeScript code compatible with any HTTP client (fetch, Axios, ky, ofetch, got) and state management/query library (TanStack Query, SWR, RTK Query). In Zod mode, you can also parse API responses at runtime before passing data to your UI components.
Is my proprietary API specification stored or sent to third parties?
No. Your specification is processed in an isolated in-memory environment exclusively to perform the dereferencing and code generation. We do not store, log, cache, or transmit your API endpoints, data models, or credentials.
Does it support Swagger 2.0 as well as OpenAPI 3.0 and 3.1?
Yes. Both legacy Swagger 2.0 specifications (which use the "definitions" object) and modern OpenAPI 3.0.x and 3.1.x specifications (which use "components.schemas") are fully supported with all native data types.
How does it handle optional properties and nullable fields?
Properties that are omitted from the "required" array in an OpenAPI schema are automatically marked with the TypeScript optional modifier ("?:"). Fields marked with "nullable: true" (OpenAPI 3.0) or type unions containing "null" (OpenAPI 3.1) are typed with "| null" in TypeScript.

Developer Reference & Learning Hubs