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

OpenAPI TypeScript Code Generation Online

Paste an OpenAPI specification and instantly generate TypeScript types for every schema and API operation. Everything runs in your browser — your spec is never uploaded.

← 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

Why generate TypeScript from OpenAPI?

OpenAPI specifications define your API's contract — the request and response shapes, parameter types, and available endpoints. Generating TypeScript types from this contract ensures your frontend code stays in sync with your API, catching type mismatches at compile time rather than runtime. This is especially valuable in large codebases where APIs evolve frequently.

How does online codegen compare to CLI tools?

CLI tools like openapi-typescript-codegen (2.14M weekly npm downloads) are great for CI pipelines, but an online converter is faster for one-off tasks: reviewing a new API's types, prototyping a client, or checking what types a spec produces before committing to a code generation pipeline. DevBolt's converter handles the same core features — $ref resolution, composition types, enums — without installing anything.

Frequently Asked Questions

What OpenAPI versions are supported?

DevBolt supports OpenAPI 3.0.x, 3.1.x, and Swagger 2.0 specifications in both JSON and YAML formats. The converter auto-detects which version you're using.

Does this tool handle $ref and allOf/oneOf/anyOf?

Yes. $ref pointers within the spec are resolved to clean TypeScript type names. allOf becomes intersection types (A & B), while oneOf and anyOf become union types (A | B).

Is my API specification uploaded to a server?

No. The entire conversion runs client-side in your browser using JavaScript. Your OpenAPI spec never leaves your device.

Related Convert Tools