Loading Swagger to OpenAPI Converter...
How to Convert Swagger 2.0 to OpenAPI 3.0
Move an older Swagger 2.0 file to OpenAPI 3.0.3 without retyping it: paths, parameters, schemas and security all come across.
Paste or upload the Swagger 2.0 spec
Paste your Swagger 2.0 spec in JSON or YAML. The converter reads paths, definitions, the shared parameters and responses, and securityDefinitions:
/v2/api-docs endpoint or your API gatewayExample: Swagger 2.0 Input
An endpoint that takes a book in the request body, plus the Book definition it points at:
swagger: "2.0"
info:
title: Books
version: "1.0"
host: api.example.com
basePath: /v1
schemes: [https]
paths:
/books:
post:
consumes: [application/json]
parameters:
- in: body
name: book
required: true
schema:
$ref: '#/definitions/Book'
responses:
"201":
description: Created
definitions:
Book:
type: object
properties:
isbn:
type: integer
format: int64
example: 9780141036144Read the OpenAPI 3.0.3 output
The result is an OpenAPI 3.0.3 document. The main moves:
in: body gets one content entry per consumes media type; formData fields become an object schema, with file fields as binary stringsschema, and collectionFormat becomes style/explode$ref is rewritten to the new locationExample: Generated OpenAPI 3.0 Output
This is exactly what the converter writes for the Step 1 input. Note the ISBN example keeps every digit:
openapi: 3.0.3
info:
title: Books
version: '1.0'
servers:
- url: https://api.example.com/v1
paths:
/books:
post:
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Book'
required: true
responses:
'201':
description: Created
components:
schemas:
Book:
type: object
properties:
isbn:
type: integer
format: int64
example: 9780141036144Copy or download it, then validate
Download the converted spec as YAML or JSON and validate it before deploying:
What is Swagger 2.0 to OpenAPI 3.0 Migration?
Swagger 2.0 (also called OAS 2) was the dominant API description format until 2017, when the OpenAPI Initiative released OpenAPI 3.0. The upgrade introduced a cleaner structure: body parameters became a first-class requestBody object, definitions moved to components/schemas, and a list of servers replaced the single host/basePath pair.
The migration involves several structural changes: Swagger's in: body parameters are replaced with a requestBody with a content map keyed by media type. The securityDefinitions object maps to components/securitySchemes, with basic becoming http/basic and OAuth2 flows renamed (accessCode → authorizationCode). $ref paths update from #/definitions/ to #/components/schemas/.
Current tools such as Swagger UI, Redocly, OpenAPI Generator and Postman work with OpenAPI 3.0, and some newer ones no longer read Swagger 2.0 at all. Validate your converted spec with our OpenAPI Validator.
Common Use Cases
Legacy API Modernisation
Upgrade Swagger 2.0 specs from older codebases, API gateways, or third-party providers to OpenAPI 3.0 so you can use modern tooling. After converting, use our OpenAPI to TypeScript or OpenAPI to Go generators to produce typed client code.
Toolchain Compatibility
Many newer tools expect OpenAPI 3: Redocly CLI, Stoplight and the current OpenAPI Generator templates all work best with it. Convert once and keep editing the 3.0 file from then on.
Frequently Asked Questions
What changes does the converter make?
host, basePath and schemes become one servers entry per scheme. An in: body parameter becomes a requestBody with one content entry per consumes media type, and formData fields become a multipart/form-data or application/x-www-form-urlencoded requestBody (type: file turns into type: string, format: binary). Query, path and header parameters get a schema object, and collectionFormat becomes style and explode. Responses get one content entry per produces type, with their headers and examples. definitions, shared parameters and shared responses move under components, securityDefinitions become securitySchemes, and every $ref is rewritten to its new place.
Will my numbers and examples change?
No. Defaults, examples, enums and limits are copied exactly as they are written, in both YAML and JSON output. A long ID like 8901240544102066246 keeps every digit, 14.50 keeps its trailing zero, and a quoted "00501" stays a string. An unquoted 00501 in YAML is kept as the text "00501" rather than being read as the number 501.
Does the output need manual fixes after conversion?
For most specs, no. A few things have no exact counterpart, and the note box above the output lists them when they occur: collectionFormat tsv, references to other files (left as they are), operations without responses, and component names with characters OpenAPI 3 does not allow, such as the Page«Pet» names Springfox writes, which are renamed together with every $ref to them. Validate the result before you publish it.
How are security definitions and OAuth2 flows migrated?
basic becomes type: http with scheme: basic, and apiKey keeps its name and location. OAuth2 flows get their OpenAPI 3 names: implicit and password stay the same, application becomes clientCredentials and accessCode becomes authorizationCode. Each flow keeps only the URLs it uses, so an implicit flow has an authorizationUrl and no tokenUrl. Scopes, descriptions and x- extensions are copied across.
Can I convert a spec that is already OpenAPI 3?
There is nothing to convert, so the page tells you so instead of producing output. Only files whose swagger field says 2.0 are converted. If a YAML file writes swagger: 2.0 without quotes it is still accepted, with a note, even though the Swagger spec wants the quoted text.
Can I paste JSON or only YAML?
Both. Input that starts with { is read as JSON and anything else as YAML. A syntax error is reported with its line and column. Either way you can pick YAML or JSON for the output, and Copy and Download always give you exactly what is on screen.
Is my spec uploaded anywhere?
No. The conversion runs in your browser and the spec is not sent to our server. Nothing is kept either: a reload starts with an empty editor.
Related: check the result with the OpenAPI Validator, switch formats with OpenAPI YAML to JSON, or read the OAuth2 authentication guide for the new security schemes.
Related Tools
OpenAPI Validator
Validate OpenAPI 3.0 and Swagger 2.0 specifications online. Check required fields, paths, operations, schemas, and security schemes with instant error reporting.
JSON to OpenAPI
Generate OpenAPI/Swagger specifications from JSON examples. Infer data types and create complete API schemas automatically.
OpenAPI Fixer
Fix broken OpenAPI and Swagger specifications automatically, repair malformed paths, schemas, $ref references, and YAML syntax errors
OpenAPI to Rust
Turn the schemas in an OpenAPI or Swagger spec into Rust structs and enums with serde attributes.
OpenAPI to Go
Generate type-safe Go structs with JSON tags from OpenAPI 3.0 and Swagger 2.0 specifications.
OpenAPI to TypeScript
Convert OpenAPI 3.0 and Swagger 2.0 specifications to TypeScript interfaces and types. Auto-generate type-safe TypeScript from any OpenAPI schema.