DevBolt
Processed in your browser. Your data never leaves your device.

Swagger to TypeScript Converter Online

Convert Swagger 2.0 specs to TypeScript types instantly. Paste your swagger.json or YAML file and get properly typed interfaces for every definition and API operation.

← Back to tools

OpenAPI to TypeScript Converter

Paste an OpenAPI 3.x or Swagger 2.0 spec (JSON or YAML) and generate TypeScript interfaces, types, and API operation types. Handles $ref resolution, allOf/oneOf/anyOf, enums, and nested objects.

Options

Samples:

How It Works

Schema Conversion

Extracts all schemas from components.schemas (OpenAPI 3.x) or definitions (Swagger 2.0) and generates TypeScript interfaces or type aliases with proper types, optional fields, and nested objects.

$ref Resolution

Follows $ref pointers within the spec to resolve references to other schemas, producing clean type names (e.g., $ref: "#/components/schemas/Pet" Pet).

Composition Types

Handles allOf (intersection types), oneOf and anyOf (union types), and enum values as string literal unions.

API Operation Types

Optionally generates typed path parameters, query parameters, request bodies, and response types from your API's path definitions. Uses operationId for naming.

Supported Features

Schema Types: string, number, integer, boolean, object, array
Composition: allOf, oneOf, anyOf, $ref
Enums: String and numeric enum → union types
Nullable: nullable: true → Type | null
Maps: additionalProperties → Record<string, T>
Output: interface or type alias, export, readonly, JSDoc
Specs: OpenAPI 3.0.x, 3.1.x, Swagger 2.0
Operations: Path, query, body, and response types

Swagger 2.0 vs OpenAPI 3.x

Swagger 2.0 stores schemas under 'definitions' and uses 'consumes'/'produces' for content types. OpenAPI 3.x moved schemas to 'components.schemas' and introduced 'requestBody' and 'content' negotiation. DevBolt's converter handles both formats transparently — just paste your spec and it auto-detects the version.

Migrating from Swagger to OpenAPI

If you're still on Swagger 2.0, generating TypeScript types from your spec is a good first step toward understanding your API surface before migrating. The generated types will be identical regardless of spec version, so you can migrate your spec without changing your TypeScript code.

Frequently Asked Questions

Can I convert swagger.json to TypeScript?

Yes. Paste your swagger.json content directly into the input field. The converter auto-detects JSON format and the Swagger 2.0 version, then generates TypeScript interfaces from every definition.

What's the difference between Swagger and OpenAPI types?

The generated TypeScript types are identical. The main difference is where schemas are stored in the spec: 'definitions' (Swagger 2.0) vs 'components.schemas' (OpenAPI 3.x). DevBolt handles both automatically.

Related Convert Tools