Free tool
Convert Swagger 2.0 to OpenAPI 3.0
Paste a Swagger 2.0 spec in YAML or JSON. You get an OpenAPI 3.0.3 document back, in YAML or JSON. It runs in your browser, so nothing is uploaded.
openapi: 3.0.3
info:
title: Pet Store
version: 1.0.0
servers:
- url: https://api.example.com/v1
paths:
/pets:
get:
operationId: listPets
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Pet'
parameters: []
post:
operationId: createPet
parameters: []
responses:
'201':
description: Created
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
components:
schemas:
Pet:
type: object
required:
- id
- name
properties:
id:
type: integer
name:
type: string
What changes
The same endpoint before and after. Lines starting with - are Swagger 2.0, lines starting with + are what the converter writes.
- swagger: "2.0"- host: petstore.example.com- basePath: /v1- schemes: [https]+ openapi: 3.0.3+ servers:+ - url: https://petstore.example.com/v1paths:/pets:post:- consumes: [application/json]- parameters:- - in: body- name: pet- schema: { $ref: '#/definitions/Pet' }+ requestBody:+ content:+ application/json:+ schema: { $ref: '#/components/schemas/Pet' }- definitions:+ components:+ schemas:Pet: ...
Every mapping it makes
- host, basePath, schemes
- Become one
serversentry per scheme. - in: body
- Becomes
requestBody, with one media type per entry inconsumes. - in: formData
- Becomes a
multipart/form-datarequest body with an object schema. If the API takesapplication/x-www-form-urlencoded, change the media type. - Response schemas
- Move under
content, with one media type per entry inproduces. - definitions
- Move to
components.schemas, and every$refis rewritten to match. - Other parameters
typeandformatmove inside aschemaobject, as 3.0 requires.- securityDefinitions
- Move to
components.securitySchemes.basicbecomeshttpwithscheme: basic.apiKeyis kept.
After converting
- 1
Validate it
Run the output through the OpenAPI Validator. - 2
Fix OAuth2 by hand
OAuth2 schemes are copied over unchanged. In 3.0 they need aflowsobject, so rewrite them yourself. - 3
Lint it
The OpenAPI Linter finds missingoperationIds, summaries and error responses. - 4
Update CI
Point your validation and code generation at the 3.0 file from now on.
Migrated. Now host it.
Specway builds a docs site from the OpenAPI 3 file you just produced. It reads Swagger 2.0 too, if you are not ready to switch. Free for one API: create an account.
- A page per endpoint
- Parameters, request body and responses read from the spec, grouped by tag in the sidebar.
- llms.txt and mcp.json
- Every docs site serves both, built from the same spec, so AI agents can read your API.
- Playground
- Fill in the parameters and send a real request from the docs page.
Questions
How do I convert Swagger 2.0 to OpenAPI 3?+
Paste the Swagger 2.0 spec above. The converter moves host, basePath and schemes to servers, body parameters to requestBody, definitions to components.schemas, and securityDefinitions to components.securitySchemes, and rewrites $refs to match. Pick YAML or JSON for the output.
What's actually different between Swagger 2 and OpenAPI 3?+
OpenAPI 3 replaced host, basePath and schemes with servers; body parameters with requestBody; definitions with components.schemas; and global consumes and produces with a media type on each request body and response. It also added callbacks, links and more security scheme types.
Should I migrate to OpenAPI 3?+
Usually yes. Most current tools target 3.0 or 3.1 first. The conversion is mostly mechanical, so run it, validate the output, and review the parts listed above.
Are all features migrated?+
The structural changes are. Check three things by hand: OAuth2 security schemes, which are copied unchanged and need a flows object in 3.0; form parameters, which always become multipart/form-data; and x- extensions, which are kept as they are.
What's the difference between OpenAPI 3.0 and 3.1?+
3.1 uses JSON Schema 2020-12 for schemas. type can be a list such as [string, null] instead of nullable: true, exclusiveMaximum is a number, and webhooks are supported. This tool writes 3.0.3 because more tools support it.
Will my existing tooling break?+
Tools that read OpenAPI 3.0, which is most of them, will read the output. Tools that only read Swagger 2.0, such as swagger-codegen 2.x, will not. openapi-generator is the usual replacement.
See your docs in a minute
Paste the link to your OpenAPI file. Free for one API, no card needed.