How to validate api response json against your contract
- Step 1Capture a live API response — Make the API call from Postman, Insomnia, or the browser DevTools Network tab. Copy the full response body JSON.
- Step 2Validate syntax — Paste the response and validate. A green pass means the response is syntactically valid JSON. An error shows the exact position and type of the syntax problem.
- Step 3Generate a schema and validate structure — For structural validation, use the JSON Schema Generator to infer a schema from the expected response shape. Then use AJV or the JSON Validator with schema mode to check that the live response conforms to the schema.
- Step 4Add contract tests to your test suite — Write a contract test that makes the real API call and validates the response against the JSON Schema: assert ajv.validate(schema, response). Run this in CI against the actual upstream API to detect breaking changes before they affect the integration.
Frequently asked questions
How do I validate multiple API response formats — for example, success and error responses?+
Generate a separate JSON Schema for each response shape. For error responses, generate the error schema from a sample 4xx/5xx response. Validate each response against the corresponding schema based on the HTTP status code — 2xx responses validate against the success schema, 4xx responses validate against the error schema.
What is consumer-driven contract testing?+
Consumer-driven contract testing (Pact) reverses the validation direction: the API consumer defines the expected response shape and publishes it as a contract. The API provider runs tests to prove it fulfills all consumer contracts. This prevents breaking changes to APIs that are consumed by multiple clients.
Is the API response data transmitted to JAD Apps?+
No. Validation runs entirely in your browser. Live API responses with customer data are never transmitted to JAD Apps servers.
Privacy first
Conversion runs locally in your browser. No file is uploaded — only metadata counters are saved for signed-in dashboard stats.