ProductCompareToolsPricingBlog
Sign inCreate an account

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.

Swagger 2.0→OpenAPI 3.0
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.

openapi.yaml
- swagger: "2.0"
- host: petstore.example.com
- basePath: /v1
- schemes: [https]
+ openapi: 3.0.3
+ servers:
+ - url: https://petstore.example.com/v1
paths:
/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 servers entry per scheme.
in: body
Becomes requestBody, with one media type per entry in consumes.
in: formData
Becomes a multipart/form-data request body with an object schema. If the API takes application/x-www-form-urlencoded, change the media type.
Response schemas
Move under content, with one media type per entry in produces.
definitions
Move to components.schemas, and every $ref is rewritten to match.
Other parameters
type and format move inside a schema object, as 3.0 requires.
securityDefinitions
Move to components.securitySchemes. basic becomes http with scheme: basic. apiKey is kept.

After converting

  1. 1

    Validate it

    Run the output through the OpenAPI Validator.
  2. 2

    Fix OAuth2 by hand

    OAuth2 schemes are copied over unchanged. In 3.0 they need a flows object, so rewrite them yourself.
  3. 3

    Lint it

    The OpenAPI Linter finds missing operationIds, summaries and error responses.
  4. 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.

Related tools

  • OpenAPI ValidatorCheck the converted spec.
  • OpenAPI LinterMissing operationIds, summaries and tags.
  • OpenAPI ViewerList the endpoints in a spec.
  • OpenAPI to TypeScriptTypes from the schemas in a spec.

See your docs in a minute

Paste the link to your OpenAPI file. Free for one API, no card needed.

Get startedSee pricing

API reference docs from your OpenAPI file.

Product

  • How it works
  • Endpoint pages
  • Code samples
  • Spec sync
  • Spec changes
  • API versions
  • Changelog
  • Recipes
  • Docs assistant
  • Your domain and look
  • Insights
  • Private docs
  • Team SSO
  • Pricing

Compare

  • vs ReadMe
  • vs Mintlify
  • vs Redocly
  • vs Scalar
  • vs Swagger UI
  • vs Postman
  • All comparisons

Tools

  • OpenAPI validator
  • OpenAPI diff
  • Swagger 2 to OpenAPI 3
  • cURL to code
  • JWT decoder
  • YAML and JSON
  • All tools

Resources

  • Guides
  • OpenAPI errors
  • Glossary
  • Public API specs
  • Blog
  • Help

Company

  • About
  • Contact
  • Privacy
  • Terms

© 2026 Specway. Made in Utah by Modlific LLC.

GitHubXLinkedIn