OpenAPI / Swagger Formatter Online

Format and validate OpenAPI and Swagger specs in JSON or YAML, and count paths and operations, right in your browser.

This is a local tool: it runs entirely in your browser. The OpenAPI or Swagger spec you paste never leaves your device — nothing is uploaded to ArrayKit or any server.

Built and maintained by Udit Agarwal

Convert between YAML and JSON

About OpenAPI / Swagger Formatter

The ArrayKit OpenAPI formatter beautifies and validates OpenAPI and Swagger specifications in either JSON or YAML, all inside your browser. Paste a spec and it parses the document, reports the detected version (OpenAPI 3.x or Swagger 2.0), the API title, and counts how many paths and operations it defines, then re-emits clean, consistently indented JSON or YAML. It is built for backend and API developers, technical writers, and platform teams who need a quick way to tidy a hand-edited contract, convert between JSON and YAML, or sanity-check a spec before committing it or feeding it to Swagger UI, code generators, or a gateway. Because the request building and parsing happen locally, you can format internal or unreleased API definitions without sending them to a server. Use it to catch malformed YAML, confirm operation counts, and standardize formatting across a repo.

Features

  • Accepts both JSON and YAML input — JSON is valid YAML, so either parses
  • Detects and labels the spec version: OpenAPI 3.x or Swagger 2.0
  • Reports the API title plus a live count of paths and operations
  • Counts the eight HTTP operations (get, put, post, delete, options, head, patch, trace)
  • Toggle the output between pretty-printed JSON and 2-space YAML
  • Surfaces parse errors with the underlying message when a document is malformed
  • Warns when no openapi or swagger field is present so unknown specs stand out
  • Download the formatted result as openapi.json or openapi.yaml

How to use the OpenAPI / Swagger Formatter

  1. Paste your OpenAPI or Swagger spec (JSON or YAML) into the input panel
  2. Pick the output format with the JSON / YAML toggle in the toolbar
  3. Read the summary banner for the version, title, path count and operation count
  4. Copy the formatted spec or download it as openapi.json or openapi.yaml

Example

Input

openapi: 3.0.3
info: { title: Example API, version: 1.0.0 }
paths:
  /users:
    get: { summary: List users, responses: { '200': { description: OK } } }
    post: { summary: Create user, responses: { '201': { description: Created } } }

Output

openapi: 3.0.3
info:
  title: Example API
  version: 1.0.0
paths:
  /users:
    get:
      summary: List users
      responses:
        '200':
          description: OK
    post:
      summary: Create user
      responses:
        '201':
          description: Created

A minimal OpenAPI 3.0 spec — the formatter reports 'OpenAPI 3.0.3 · Example API · 1 path · 2 operations'.

Common errors & troubleshooting

  • The summary shows 'Unknown — no openapi/swagger field'. — Add a top-level openapi: 3.x.x (or swagger: '2.0') field; without it the version can't be detected even though the document still formats.
  • A YAML parse error appears, often about bad indentation or a tab character. — YAML is indentation-sensitive and forbids tabs — replace tabs with spaces and align keys consistently, then re-paste.
  • Operation count looks lower than expected. — Only the eight standard HTTP methods are counted; vendor extensions like x-amazon-apigateway-integration and parameters/servers entries are not operations.
  • 'The document is empty or not an object' after pasting. — The input parsed to a scalar or null — make sure you pasted the whole spec object, not a single string or a partial fragment.

Frequently asked questions

What is an OpenAPI / Swagger formatter?
It is a tool that parses an OpenAPI 3.x or Swagger 2.0 API specification and re-emits it as clean, consistently indented JSON or YAML, while reporting the version and the number of paths and operations so you can quickly review and standardize a spec.
Does it support both JSON and YAML specs?
Yes. Because JSON is itself valid YAML, you can paste either format. Use the JSON / YAML toggle to choose how the formatted output is emitted, which also lets you convert a spec from one format to the other.
Does it fully validate my spec against the OpenAPI schema?
It validates that the document parses as well-formed JSON or YAML and detects the version, title, paths and operations. It does not run full JSON Schema validation of every field, so it will not flag a missing required property deep inside an operation.
What versions does it recognize?
It labels OpenAPI 3.x via the openapi field and Swagger 2.0 via the swagger field. Any document without one of those fields is formatted but marked as an unknown version.
Is my API spec uploaded anywhere?
No. Parsing, validation and formatting run entirely in your browser. The spec you paste never leaves your device and nothing is uploaded to ArrayKit, so internal or unreleased API contracts stay private.
Can I download the formatted result?
Yes. The formatted spec can be copied or downloaded as openapi.json or openapi.yaml depending on the output format you selected.

Related tools

  • YAML ↔ JSON — Convert YAML to JSON and back.
  • JSON Formatter — Beautify, minify and validate JSON with error locations.
  • GraphQL Formatter — Format or minify GraphQL queries and schemas, validate syntax and extract operations.
  • XML Formatter — Beautify, minify and validate XML, and convert XML ↔ JSON.
  • API Request Client — Send HTTP requests, build headers and params, inspect responses — your last 25 requests are saved locally.
  • cURL to Fetch — Convert a curl command to a JavaScript fetch() call.
  • JSON Viewer — Text + collapsible tree viewer with expand/collapse and node paths.
  • Markdown Preview — Render Markdown to HTML with a live preview.

Guides

More Code Formatters tools

  • CSS Unit Converter — Convert between px, rem, em, pt and % live with a configurable root font size.
  • Glob to Regex — Convert a glob or wildcard pattern into an equivalent JavaScript regex.
  • HTML to Markdown — Paste HTML and convert it to clean Markdown live, with GFM tables, lists and code blocks.
  • TOML Formatter & Converter — Format and validate TOML, and convert TOML ↔ JSON.
  • logfmt to JSON — Convert logfmt key=value logs to JSON and back.
  • dotenv to JSON — Convert a .env file to JSON and JSON back to .env, with quoting and comments handled.
  • CSV to Markdown Table — Convert CSV or TSV data into a Markdown table, with alignment and header options.
  • INI to JSON — Convert INI config files to JSON and JSON back to INI, with sections and comments.
  • Markdown Table Generator — Build a table in an editable grid and export Markdown, HTML, AsciiDoc and LaTeX.
  • Data Size Converter — Convert between bits, bytes, KB, MB, GB and KiB, MiB, GiB, with decimal and binary units.
  • Java Properties ↔ JSON — Convert Java .properties files to JSON and JSON back to .properties, in your browser.
  • YAML ↔ JSON — Convert YAML to JSON and back.

See all Code Formatters tools (32) · All tools