OpenAPI / Swagger Formatter
Format and validate OpenAPI / Swagger specs (JSON or YAML) and count paths and operations.
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.
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
- Paste your OpenAPI or Swagger spec (JSON or YAML) into the input panel
- Pick the output format with the JSON / YAML toggle in the toolbar
- Read the summary banner for the version, title, path count and operation count
- 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.
All ArrayKit tools