YAML to Swagger converter
Paste an OpenAPI or Swagger YAML file to get the same spec as JSON, a list of every endpoint, and clear messages for syntax errors and missing fields.
Runs in your browser. Nothing you enter is uploaded.
How to use the YAML to Swagger converter
- Paste your OpenAPI 3 or Swagger 2.0 YAML into the left box, or click Example.
- The JSON version appears on the right; choose 2 or 4 spaces of indentation.
- Check the status line, any warnings and the endpoint list under the boxes.
- Click Copy, or Download to save it as openapi.json or swagger.json.
What is the difference between Swagger and OpenAPI?
They are the same specification at different points in time. Swagger 2.0 was donated to the OpenAPI Initiative in 2015 and renamed; the next major version was released as OpenAPI 3.0 in 2017. Today "Swagger" usually refers to the tools around the spec, such as Swagger UI and Swagger Editor, while the format itself is called OpenAPI.
You can tell them apart by the first field: a Swagger 2.0 file starts with swagger: "2.0", an OpenAPI file with openapi: 3.0.3 or openapi: 3.1.0. This converter handles both and shows which one it found in the status line.
Why convert an API spec from YAML to JSON?
YAML is easier for people to read and write, which is why most specs are edited in YAML. JSON is easier for programs: some tools, code generators and API gateways only accept a JSON file, and JSON can be loaded in any language without an extra library. Both formats describe exactly the same document, so converting loses nothing.
Anchors and merge keys, which YAML supports and JSON does not, are expanded into full copies in the JSON output. $ref references are plain strings in both formats and are kept exactly as written.
Common YAML mistakes in API specs
Indentation must use spaces, never tabs, and every level must line up. An unquoted value that contains a colon followed by a space, such as a description with "Note: …" in it, is read as a new key and causes an error; put such values in quotes. When the YAML cannot be read, the tool shows the problem and the line number so you can jump straight to it.
Version numbers are another trap: written without quotes, swagger: 2.0 is read as the number 2, which is not a valid Swagger version. The converter writes it back as the string "2.0" and warns you, but it is better to quote it in your YAML.
Frequently asked questions
Does this check that my OpenAPI spec is valid?
Partly. It reports YAML syntax errors with the line number and warns when the version field, info.title, info.version or paths are missing. It does not validate every field against the full OpenAPI schema, so run a dedicated validator before publishing a spec that others depend on.
Can I convert Swagger JSON back to YAML?
Yes. Paste the JSON into the left box and click JSON → YAML. The box is replaced with the YAML version, and the JSON on the right is generated again from it, so you can check the round trip.
Which versions are supported?
Swagger 2.0 and OpenAPI 3.x, including 3.0 and 3.1. The tool reads the swagger or openapi field to tell them apart and lists the endpoints of either. Download names the file swagger.json for Swagger 2.0 and openapi.json for OpenAPI.
Why are some endpoints missing from the list?
The list shows operations under paths that use one of the HTTP methods get, put, post, delete, options, head, patch or trace. Other keys under a path, such as parameters or summary, are not operations and are not listed, but they are kept in the JSON.
Is my API spec uploaded anywhere?
No. The conversion runs entirely in your browser, so internal or unreleased API definitions never leave your device. Your last input is remembered in your browser's local storage so it is still there when you return.