How to Use Fake JSON Data in Postman Collections
Postman is the most widely used API testing tool, and fake JSON data unlocks three of its most powerful features: mock servers, data-driven collection runs, and example responses. This guide covers all three workflows.
Workflow 1: Mock Server with Example Responses
A Postman Mock Server returns canned responses for any endpoint you define — without a real backend. This is the fastest way to give your frontend team an API to build against.
Setup
- In Postman, create a new Collection (e.g., "My App API")
- Add a request:
GET /users - Click the request → Examples tab → Add Example
- Set the response status to
200and paste your generated JSON as the response body - Back in the Collection sidebar → ··· → Mock Collection
- Name it and click Create Mock Server
Postman gives you a URL like https://abc123def456.mock.pstmn.io. Anyone on your team can now GET https://abc123def456.mock.pstmn.io/users and get back your example response.
Multiple Response Scenarios
Add multiple examples per request to simulate different scenarios:
GET /users
├── Example: 200 Success → array of user objects
├── Example: 200 Empty → []
├── Example: 401 Unauthorized → { "error": "Unauthorized" }
└── Example: 500 Server Error → { "error": "Internal server error" }To trigger a specific example, add the x-mock-response-name header to your request:
GET https://abc123.mock.pstmn.io/users
x-mock-response-name: 200 EmptyWorkflow 2: Data-Driven Testing with CSV
Postman's Collection Runner can iterate a request using rows from a CSV file — one request execution per row. This lets you test your API against hundreds of different inputs in one click.
Step 1: Generate a CSV data file
Open Dummy JSON Generator, configure fields that match your API's request body (e.g., email, firstName, role), set the record count to 100, and export as CSV.
email,firstName,role
ayesha.rahman@test.com,Ayesha,admin
james.obrien@test.com,James,user
priya.sharma@test.com,Priya,userStep 2: Use CSV variables in your request
In Postman, reference CSV column names as variables using double curly braces:
POST /api/users
Content-Type: application/json
{
"email": "",
"firstName": "",
"role": ""
}Step 3: Add test assertions
// Postman Tests tab
pm.test("Status is 201", () => {
pm.response.to.have.status(201);
});
pm.test("Response contains created user", () => {
const body = pm.response.json();
pm.expect(body.email).to.eql(pm.variables.get("email"));
pm.expect(body.firstName).to.eql(pm.variables.get("firstName"));
});Step 4: Run the Collection
- Click your Collection → Run Collection
- Under Data, click Select File → upload your CSV
- Postman shows "100 iterations" (one per CSV row)
- Click Run
You just tested your user creation endpoint against 100 different realistic inputs in about 10 seconds.
Workflow 3: Environment Variables for Different Datasets
Store different JSON datasets as Postman environment variables to quickly switch between scenarios:
// Pre-request Script — loads fake user data into a variable
const users = [
{ "id": 1, "email": "ayesha@test.com", "role": "admin" },
{ "id": 2, "email": "james@test.com", "role": "user" }
];
pm.environment.set("testUsers", JSON.stringify(users));
pm.environment.set("testUser", JSON.stringify(users[0]));// Request body uses the variable
{
"user":
}Workflow 4: Newman CLI for CI/CD
Newman runs Postman collections from the command line — including data-driven runs with your CSV file. Add it to your CI pipeline to run API tests on every push:
npm install -g newman
# Basic run
newman run MyCollection.json
# Data-driven run with your generated CSV
newman run MyCollection.json \
--data test-data.csv \
--reporters cli,json \
--reporter-json-export results.json# GitHub Actions example
- name: Run API tests
run: |
newman run ./postman/collection.json \
--environment ./postman/env.json \
--data ./test-data/users.csvUseful Field Combos for Postman CSV Data
| API Endpoint | Fields to Generate |
|---|---|
| POST /users (register) | firstName, lastName, email, password, phone |
| POST /orders | productId (integer), quantity (integer), address, city, country |
| POST /payments | amount (price), currency, status (enum: pending/success/failed) |
| POST /events (analytics) | uuid, eventType (enum), timestamp, ip, country, deviceType |
Generate each set at Dummy JSON Generator using CSV export. Your Postman data-driven tests will run through all rows automatically.