SoftwareTestPilot
API TestingPublished: 8 min read

How to Validate JSON API Responses in Postman (Complete Guide)

Validate REST responses with pm.expect, JSON schema, JSONPath, and JMESPath. A step-by-step Postman guide with copy-paste snippets and a free JSON tester.

Avinash K
Founder & QA Engineer at SoftwareTestPilot
Share:XLinkedInWhatsApp
Postman JSON response validation examples
Postman JSON response validation examples

2026-07-17 · By Avinash K

Every mature API test suite validates three things about a JSON response: shape (schema), values (assertions), and contracts (types). This guide shows how to do all three in Postman without leaving the app.

1. Value assertions with pm.expect

const body = pm.response.json();
pm.test("status is 200", () => pm.response.to.have.status(200));
pm.test("first product name", () => {
  pm.expect(body.data[0].name).to.eql("Widget");
});
pm.test("all prices are positive", () => {
  body.data.forEach(p => pm.expect(p.price).to.be.above(0));
});

2. Schema validation with ajv

const schema = {
  type: "object",
  required: ["id", "name", "price"],
  properties: {
    id: { type: "integer" },
    name: { type: "string", minLength: 1 },
    price: { type: "number", minimum: 0 }
  }
};
pm.test("body matches schema", () => {
  pm.response.to.have.jsonSchema(schema);
});

3. Filter with JSONPath before asserting

const paid = body.orders.filter(o => o.status === "paid");
pm.test("we have exactly 3 paid orders", () => {
  pm.expect(paid.length).to.eql(3);
});

Prototype the JSONPath in the free JSON / JSONPath / JMESPath Tester, copy the working expression into Postman.

4. Data-driven runs

Use Postman's Runner with a CSV file to loop the same assertions across many payloads. Combine with the schema step above to catch contract regressions across environments.

5. Move complex assertions into code

Beyond ~10 assertions per request, prefer a real testing framework. Convert the collection to Playwright, Rest Assured, or k6 with the free Postman → Code Converter.

Frequently asked questions

1.How do I compare two JSON payloads in Postman?
Store the baseline in an environment variable, then use lodash.isEqual (available in the sandbox) inside pm.test.
2.Can Postman validate nested arrays?
Yes — either use nested pm.expect or ajv with an items schema.
3.How do I avoid duplicated test scripts?
Put shared logic in a collection-level Pre-request or Tests tab; every request inherits it.
4.What if the response is huge?
Assert on the fields that matter. Use JSONPath to slice first, then assert.