How to generate mock json examples for postman collections
- Step 1Pick the endpoint you are documenting — The fixed shape suits a user/person endpoint. For other resources, plan to rename/trim fields after generating so the saved example matches the real response.
- Step 2Generate the success body — Set count to 1 for a single-object example or to a small number for a list example, choose a seed (default
42), and click Generate Mock Data. Output is pretty-printed JSON ready to paste. - Step 3Add the example to the Postman request — Open the request in Postman, go to the request's Examples, add an example, and paste the generated JSON as the response body. Set the status code (e.g. 200) and a
Content-Type: application/jsonheader. - Step 4Author error examples by hand — The generator only emits success records. Add 400/401/404/500 examples manually with the appropriate error body and status code so the collection documents the full surface.
- Step 5Reshape if the endpoint is not a user resource — Run the generated record through json-key-renamer and json-key-filter so the saved example's fields match your real response before you paste it in.
- Step 6Enable the mock server — With examples saved, choose Mock Collection in Postman. The mock returns the saved example for each matched request; because your example is realistic and deterministic, consumers get a believable, stable response.
What the generator covers for a Postman collection
Success bodies come from the generator; everything else around them you author in Postman.
| Collection element | From generator? | How |
|---|---|---|
| 200 success body (single) | Yes | Count 1 — paste as the example body |
| 200 success body (list) | Yes | Set count, paste the array |
| Status code + Content-Type | No | Set on the saved example in Postman |
| 4xx / 5xx error examples | No | Author the error body by hand |
| Pagination envelope | No | Wrap the array manually before pasting |
| Endpoint-specific fields | No | Reshape with json-key-renamer |
Generated record vs a typical user response
How the fixed fields line up with a common user endpoint, and what to rename.
| Generated field | Typical API field | Action |
|---|---|---|
id | id / user_id | Keep, or rename |
name | name / fullName | Often rename to camelCase |
email | email | Keep |
status | status / state | Keep, or rename |
createdAt | created_at / createdAt | Rename to match casing |
address | nested object | Keep, or filter out if flat |
index | (usually not in API) | Filter out before pasting |
Cookbook
Recipes for turning the generated body into Postman saved examples and a mock server.
Single-object success example for GET /users/:id
ExampleGenerate one record and paste it as the 200 example body. Filter out the index field, which a real API would not return.
// Generated: count 1, seed 42 (index removed via json-key-filter)
{
"id": "ab732cc0-86ce-45f2-ad8f-78e93ffbe1ce",
"name": "Grace Davis",
"email": "grace.davis@mock.dev",
"phone": "+1-555-7711",
"age": 36,
"status": "active",
"address": { "street": "550 Cedar Blvd", "city": "Ogdenville", "zip": "10345" },
"score": 47.1,
"createdAt": "2024-01-17",
"active": false
}
// Postman: Add Example → paste as body → status 200 → Content-Type application/jsonList example for GET /users
ExampleGenerate an array for the collection endpoint's saved example. Postman's mock returns it verbatim.
// Generated: count 5, seed 42 → paste as the 200 example for GET /users
[
{ "id": "...", "name": "Grace Davis", "status": "active", ... },
{ "id": "...", "name": "Carol Smith", "status": "pending", ... }
]Pair a generated success with a hand-written 404
ExampleThe generator does not produce errors, so author them. Save both examples on the request for full documentation.
// 200 example: generated record (above)
// 404 example (authored by hand):
{
"error": "NOT_FOUND",
"message": "No user with that id",
"status": 404
}
// Set this example's status code to 404.Rename to match a documented snake_case contract
ExampleIf the real response uses snake_case, align the example so the docs are accurate.
Step 1 — generate count 1, seed 42 here.
Step 2 — json-key-renamer: name → full_name, createdAt → created_at, active → is_active
Step 3 — json-key-filter: remove index
Result:
{ "id": "...", "full_name": "Grace Davis", "created_at": "2024-01-17", "is_active": false, ... }Wrap as a paginated list example
ExampleMost list endpoints return an envelope, not a bare array. Wrap the generated array before pasting.
// Generated array (count 10) wrapped by hand:
{
"data": [ /* ...generated records... */ ],
"meta": { "page": 1, "perPage": 10, "total": 137 }
}
// Paste this whole object as the 200 example.Errors and edge cases
Real errors and silent failures sourced from each platform's own documentation. Match the wording to the row, fix what the row says to fix.
You expected it to read the endpoint schema
Not supportedThe generator does not read OpenAPI or a response schema. It emits the fixed person shape and ignores input. Reshape the output to your endpoint with json-key-renamer and json-key-filter before saving it as a Postman example.
Mock server returned placeholder text, not your data
Example not savedPostman's mock returns the saved example for the matched request. If you see auto-generated placeholders, no example was saved for that request, or the request was added without an example. Add and save the generated body as an example, then re-enable the mock.
Index field appears in the documented response
Filter it outThe generator always includes an index field (1..n) that a real API would not return. Remove it with json-key-filter before saving the example so your documentation does not advertise a field your API lacks.
No error examples in the collection
Author by handThe generator only emits success records. Add 400/401/404/500 examples manually with the right body and status code. A collection that documents only the happy path is incomplete for consumers.
Mock returns the wrong example for a request
Matching rulePostman matches a mock request by method and path and returns the saved example for it; with multiple examples it picks the first match (or one targeted by the x-mock-response-name header). This is Postman behavior, not a generator issue — name examples deliberately if you save several per request.
List example has duplicate emails
ExpectedAt larger counts, generated emails repeat because they come from a small name pool. For a documentation example a few records is enough; keep the count low so the example reads cleanly and uniquely.
Toggling Sequential IDs changed the whole example
By designThe id mode shifts the random stream, so non-id fields change at the same seed. Choose the id style that matches your real API's id type before generating the example.
Pasted body needs to be a paginated envelope
Wrap by handThe generator emits a bare array. For an endpoint that returns { data, meta }, wrap the array yourself before pasting the example so the documented shape matches the real response.
Frequently asked questions
Does the generator build examples from my endpoint schema?
No. It emits a fixed person-record shape and ignores any schema or spec. It maps well onto a user endpoint; for others, reshape the output with json-key-renamer and json-key-filter before saving it as a Postman example.
How does Postman's mock server choose which example to return?
Postman matches by HTTP method and URL path and returns the saved example for that request. With multiple examples on a request, it returns the first match, or the one named in the x-mock-response-name request header. The generator's role is only to give you a realistic body to save as that example.
Why is my mock returning placeholders instead of the generated data?
Because no example was saved for that request, or the request was added without one. Paste the generated body as a saved example, set the status code and Content-Type, save, and re-enable the mock collection. The mock returns saved examples verbatim.
Should I remove the index field before saving the example?
Usually yes. Every generated record includes an index field (1..n) that a real API would not return. Strip it with json-key-filter so the documented example does not advertise a field your endpoint lacks.
How do I add error response examples?
Author them by hand — the generator only emits success records. Add 400 (validation), 401 (unauthorized), 404 (not found), and 500 (server error) examples with appropriate bodies and status codes so the collection documents the full surface.
Can I make a paginated list example?
Yes, but wrap it yourself. Generate the array, then nest it under your envelope ({ data: [...], meta: { page, perPage, total } }) before pasting it as the example. The generator emits a bare array; the envelope is part of your contract.
Will the documented example stay the same over time?
Yes if you reuse the same seed and count. The output is deterministic, so regenerating the example produces an identical body — handy for keeping the documentation and the mock response in lockstep across collection versions.
Are the example emails and phones safe to publish in docs?
Yes. Emails use non-routable test domains and phones are always in the reserved +1-555 range, so a published example can never point at a real person. Keep example counts small to avoid duplicate emails from the small name pool.
How do I match snake_case vs camelCase in the documented example?
Decide the casing of your real response and align the generated record to it with json-key-renamer before saving the example. Accurate field names are the whole point of a documentation example.
Can I generate types or a schema from the example?
Yes — paste a record into json-to-typescript for an interface, or json-schema-generator for a JSON Schema you can attach to the contract. Validate hand-edited examples with json-validator.
Is the body minified or pretty-printed?
Always 2-space pretty-printed. That is readable for a documentation example; if you specifically need a minified body, run it through json-minifier before pasting.
Does my API design data get uploaded?
No. Generation runs entirely in your browser. The tool ignores input and the generated example body never reaches JAD Apps servers. Only an anonymous usage counter is recorded for signed-in dashboard stats.
Privacy first
Conversion runs locally in your browser. No file is uploaded — only metadata counters are saved for signed-in dashboard stats.