How to use OpenAPI Formatter
- Paste an OpenAPI or Swagger document.
- Pick the output format, indentation and sorting mode.
- Copy or download the formatted document (openapi.yaml / openapi.json).
OpenAPI Formatter features
- JSON ↔ YAML conversion with 2- or 4-space indentation
- Structural sorting: paths, component names and tags alphabetically, HTTP methods and top-level keys in canonical order, responses by status code
- Optional full canonical form with every key sorted
- Summary with detected version, size before/after and validation status
- Line-accurate parse errors for malformed input
OpenAPI Formatter example
Minified JSON to sorted YAML
Input:
{"openapi":"3.0.3","paths":{"/b":{"get":{…}},"/a":{"post":{…},"get":{…}}},"info":{"title":"X","version":"1"}}Output:
openapi: 3.0.3
info:
title: X
version: "1"
paths:
/a:
get: …
post: …
/b:
get: …Frequently asked questions about OpenAPI Formatter
What does "Sort paths, methods & components" do?
Paths and component names are ordered alphabetically, HTTP methods in the canonical order (GET, PUT, POST, DELETE, OPTIONS, HEAD, PATCH, TRACE), response codes numerically with default last, and top-level keys in the conventional OpenAPI order. Content stays identical, so the output is a stable canonical form for diffs.
Is YAML → JSON conversion lossless?
For OpenAPI documents, yes: they use only the JSON-compatible subset of YAML. Dates and binary values are converted to strings, and anchors/aliases are expanded.
Why are some keys quoted in the YAML output?
Keys such as "200", "yes" or "on" would be interpreted as numbers or booleans by YAML parsers, so they are quoted to keep them strings — exactly what OpenAPI tooling expects for response codes.
Does the formatter also validate?
It runs the structural validator and reports the error count in the summary, but it formats the document even when errors are present so you can fix it in the pretty-printed output.