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.

Step 1

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:

•
Paste directly: Copy your spec from Swagger Editor, a Springfox /v2/api-docs endpoint or your API gateway
•
Upload a file: Load a swagger.json, swagger.yaml or .yml file from disk (up to 10 MB)
•
Try the sample: Click "Sample" to load a Bookstore API with two endpoints, two definitions and an API key security scheme

Example: 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: 9780141036144
Step 2

Read the OpenAPI 3.0.3 output

The result is an OpenAPI 3.0.3 document. The main moves:

•
Body and form parameters → requestBody: in: body gets one content entry per consumes media type; formData fields become an object schema, with file fields as binary strings
•
Other parameters get a schema: type, format, limits and enums move into schema, and collectionFormat becomes style/explode
•
definitions, parameters, responses → components: and every $ref is rewritten to the new location
•
securityDefinitions → components/securitySchemes: basic becomes http, and OAuth2 flows get their OpenAPI 3 names
•
host + basePath + schemes → servers: one server URL per scheme

Example: 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: 9780141036144
Step 3

Copy or download it, then validate

Download the converted spec as YAML or JSON and validate it before deploying:

•
Validate the output: Run it through our OpenAPI Validator to catch anything left to fix
•
Generate docs: Render with Swagger UI or Redocly for interactive API documentation
•
Generate client code: Use OpenAPI Generator or openapi-typescript with your new 3.0 spec to generate typed SDK clients

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.