What is API contract testing?
An API contract is the agreed description of an interface — its endpoints, parameters, request and response schemas and status codes — usually written as an OpenAPI document. Contract testing compares what a service actually returns with that description, so a renamed field or a changed type is caught by the producer or the consumer before it breaks the other side.
Read the guide: What is API Testing? How to Test a REST API
How to use Swagger JSON Formatter
- Paste the Swagger 2.0 JSON.
- Choose pretty JSON, minified JSON or YAML and whether to sort paths and definitions.
- Copy the formatted document and review the endpoint and definition tables.
Swagger JSON Formatter features
- Pretty-print, minify or convert Swagger 2.0 JSON to YAML
- Version detection with clear warnings for OpenAPI 3.x or non-spec JSON
- Endpoint inventory (method, path, operationId, summary, tags, response codes) and definitions table
- Base URL assembled from schemes, host and basePath
- Structural validation problems listed alongside the formatted output
Swagger JSON Formatter example
Inventory a Petstore spec
Input:
{"swagger":"2.0","info":{"title":"Petstore","version":"1.0.5"},"host":"petstore.swagger.io","basePath":"/v2","paths":{"/pet/{petId}":{"get":{"operationId":"getPetById",…}}}}Output:
Specification: Swagger 2.0 · Base URL: https://petstore.swagger.io/v2
Endpoints: GET /pet/{petId} getPetById — responses 200, 404
Definitions: Pet (object) — id, name, statusFrequently asked questions about Swagger JSON Formatter
What is the difference between Swagger 2.0 and OpenAPI?
Swagger 2.0 was renamed OpenAPI 2.0 when the specification moved to the Linux Foundation. OpenAPI 3.x restructured it: host/basePath/schemes became servers, definitions became components.schemas, and body parameters became requestBody. This tool targets 2.0 documents but formats 3.x too.
What does the endpoint table show?
Every operation with its method, path, operationId, summary, tags and documented response codes — a quick inventory for reviews and test planning.
Can I minify instead of pretty-print?
Yes. Choose "Minified JSON" to produce the smallest valid document, useful for embedding in configuration or API gateways.
Does it convert Swagger 2.0 to OpenAPI 3?
No — it formats, sorts and converts between JSON and YAML only. Use a converter such as swagger2openapi for the structural migration, then validate the result with the OpenAPI Validator.
References
- OpenAPI SpecificationThe standard for describing REST APIs: paths, operations, parameters, schemas, responses and security schemes.
- JSON Schema SpecificationThe vocabulary for describing and validating the shape of JSON documents (types, required properties, formats).
- RFC 9110: HTTP SemanticsThe meaning of HTTP methods, header fields, status codes and content negotiation, independent of the wire version.