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 Kamble
Founder & QA Engineer at SoftwareTestPilot
Reviewed by Priyanka G.
Share:XLinkedInWhatsApp

2026-07-17 · By Avinash Kamble, reviewed by Priyanka G.

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.
Keep going

Practice these questions

Rehearse REST, Postman, REST Assured and contract-testing questions with worked examples.

Found this useful?
Share:XLinkedInWhatsApp

Was this article helpful?

Cluster · API Testing

More from REST API Testing

REST fundamentals — verbs, status codes, contracts.

Pillar guide · 30 articles
More in this cluster
From the API Testing pillar

Keep building your QA edge

Practice these questions live

Rehearse with an AI QA interviewer that scores your answers in real time.

Start a Free AI Mock Interview →

Continue reading

Join the QA Community

Connect with fellow testers, share job leads, and get career advice.

Premium QA Resources

Stop Reinventing the Wheel. Upgrade Your QA Arsenal.

Take your testing skills from beginner to Lead Engineer. Supercharge your daily workflow with our premium digital resources.

  • Ready-to-use testing strategy templates
  • Advanced API & UI automation guides
  • ⏱️ Save 10+ hours a week on test planning
4.9/5 rating
Explore All Products

⭐⭐⭐⭐⭐ Trusted by 1,000+ Software Test Pilots • Instant Access