How to generate json schema for postman collection and mock servers
- Step 1Capture a real API response from Postman — Send the request in Postman and copy the response body JSON. Use the most complete successful response — 200 OK with all optional fields populated.
- Step 2Generate the schema — Paste the JSON here and click Generate. The draft-07 schema captures the full response shape.
- Step 3Add the schema to a Postman Collection variable — In Postman, create a collection variable (e.g. USER_RESPONSE_SCHEMA) and paste the JSON Schema as its value. This makes the schema reusable across all tests that call the same endpoint.
- Step 4Add a test script assertion — In the Tests tab: const schema = JSON.parse(pm.collectionVariables.get('USER_RESPONSE_SCHEMA')); pm.test('Response matches schema', () => { pm.response.to.have.jsonSchema(schema); });
Frequently asked questions
How do I use the schema in a Postman mock server?+
Postman mock servers use example responses stored in the collection, not JSON Schema validation. Add the sample JSON as a saved Example on your request, and the mock server returns it verbatim. The schema is used in test scripts to validate that real responses still match the mock structure.
Will the schema work with the Postman collection runner and Newman?+
Yes. Newman uses the same test scripts as the Postman UI, so pm.response.to.have.jsonSchema(schema) assertions run identically in Newman CLI and in CI pipelines. Ensure the schema variable is included in the collection export when running Newman.
Is the API response data uploaded to JAD Apps?+
No. Schema inference runs entirely in your browser. API response bodies and endpoint-specific data structures 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.