OpenAPI to JSON — YAML Spec to JSON Converter

Convert OpenAPI / Swagger YAML specifications to formatted JSON. Supports OpenAPI 3.0, 3.1, and Swagger 2.0 — entirely in your browser.

What is OpenAPI / Swagger?

The OpenAPI Specification (formerly Swagger) describes HTTP APIs in a single machine-readable document. Swagger 2.0 was donated to the Linux Foundation and renamed OpenAPI 3.0 in 2017; OpenAPI 3.1 followed in 2021 and aligns the schema dialect with JSON Schema 2020-12. The spec can be authored in YAML (popular for human editing) or JSON (the canonical wire format consumed by tooling).

Most tooling — Postman imports, AWS API Gateway, Azure APIM, openapi-generator, swagger-codegen, Redoc — accepts JSON natively. Teams hand-edit the spec in YAML for readability and convert to JSON at build time. This page does that conversion entirely in your browser, no install, no upload.

How to convert OpenAPI YAML to JSON — 4 steps

  1. Paste OpenAPI YAML. Copy your openapi.yaml contents into the Input panel above. Click Load Sample for a Pet Store demo.
  2. Click Convert. The tool parses the YAML in JavaScript and renders the equivalent JSON tree.
  3. Review the JSON. Paths, schemas, components, and security definitions map 1:1 with your source.
  4. Use it. Copy into Postman, an SDK generator, or save it as openapi.json for your CI pipeline.

Sample input and output

Input — Pet Store YAML

openapi: 3.0.3
info:
  title: Pet Store
  version: 1.0.0
paths:
  /pets:
    get:
      summary: List pets
      responses:
        '200':
          description: OK

Output — JSON

{
  "openapi": "3.0.3",
  "info": {
    "title": "Pet Store",
    "version": "1.0.0"
  },
  "paths": {
    "/pets": {
      "get": {
        "summary": "List pets",
        "responses": {
          "200": { "description": "OK" }
        }
      }
    }
  }
}

YAML to JSON

Pretty-printed JSON output with 2-space indentation — the convention used by Stripe, GitHub, and most public specs.

OpenAPI 3.0, 3.1, Swagger 2.0

Works for any spec version. The converter walks the YAML tree without enforcing a schema, so it handles all dialects.

Client-Side Only

Conversion runs in your browser. Specs with example tokens, internal hostnames, or staging URLs never leave your device.

Common use cases

  • check_circleGenerating API documentation with Redoc, Swagger UI, or Stoplight Elements (most accept JSON natively)
  • check_circleImporting into Postman or Insomnia — both prefer JSON imports
  • check_circleFeeding openapi-generator or swagger-codegen for client SDKs in Java, Go, TypeScript, Python
  • check_circleUploading to AWS API Gateway, Azure API Management, or Google Apigee — all expect JSON
  • check_circleContract testing with Pact, Dredd, or Schemathesis
  • check_circleValidating in CI pipelines with spectral, openapi-lint, or redocly
  • check_circleDiffing API versions in pull requests
  • check_circleEmbedding the spec inside another JSON document (e.g. Helm values, Terraform variables)

Swagger 2.0 vs OpenAPI 3.0 vs OpenAPI 3.1 vs AsyncAPI

SpecYearSchema dialectUse for
Swagger 2.02014Custom subsetLegacy APIs; still common in enterprise
OpenAPI 3.02017JSON Schema (subset)Modern REST APIs; widest tooling support
OpenAPI 3.12021JSON Schema 2020-12New projects; webhooks, full JSON Schema
AsyncAPI2017JSON SchemaEvent-driven / message-based APIs (Kafka, MQTT)

Need the reverse direction?

Convert OpenAPI JSON back to YAML, or validate your spec for missing fields and broken $refs.

Frequently Asked Questions

Why convert OpenAPI YAML to JSON?

Many tooling chains require JSON: Postman imports, AWS API Gateway, Azure API Management, and most code generators (openapi-generator, swagger-codegen) accept JSON natively. YAML is preferred for hand-editing because of comments and lower visual noise, but JSON is the canonical wire format.

Does this support OpenAPI 3.1?

Yes. The converter works for any structurally valid OpenAPI / Swagger document — 2.0, 3.0.x, and 3.1. It walks the YAML tree and emits the equivalent JSON regardless of the spec version.

Are $ref pointers preserved?

Yes. $ref strings are passed through unchanged — the converter does not dereference or resolve them. If you need a fully bundled spec with all $refs inlined, use a CLI tool like swagger-cli bundle or redocly bundle.

Will my API keys or example tokens be uploaded?

No. The conversion runs entirely in JavaScript inside your browser. No request is made when you click Convert — verify in your browser DevTools Network tab. Specs containing example bearer tokens, internal hostnames, or staging URLs never leave your device.

What if my YAML has anchors or merge keys?

This minimal converter handles the YAML subset typical in OpenAPI specs (objects, arrays, scalars, multi-line block style). Anchors (&) and merge keys (<<) are uncommon in OpenAPI and are not expanded — if your spec uses them, run yq or js-yaml locally first.

How is JSON output formatted?

JSON is pretty-printed with 2-space indentation — the same convention used by Stripe, GitHub, and most public OpenAPI specs. To minify, copy the output into our JSON Minifier.

Why not just use yq or python -c "import yaml,json"?

Both work locally, but require installing tooling. This page is a zero-install browser tool — useful when reviewing a spec on a colleague's machine, in a CI log review, or on a locked-down work laptop where pip / brew are restricted.

Can I convert a Swagger 2.0 file?

Yes. Swagger 2.0 (which uses the swagger: "2.0" field instead of openapi:) is just YAML — the converter treats it the same way. The output is valid Swagger 2.0 JSON.

OpenAPI to JSON Converter — YAML Spec to JSON Online