Mock JSON Data Generator for API Fixtures
Generate and download mock JSON records for API clients and fixture files. Check data types, null handling and reproducibility before importing.
Preview
Example| name | |
|---|---|
| Tess Example | [email protected] |
Test fixture
[{"name":"Tess Example","email":"[email protected]"}]Download a JSON array of test records
Use the generator to make a small batch of synthetic contacts and select Download JSON. Each array element is a record with a name and an example email. Open the output in a JSON parser to check the keys and types before committing it as a fixture. Keep external traffic disabled in the test environment even when the email uses an example domain.
Treat the HTTP envelope as a separate fixture. If your client expects an object with items and a paging cursor, wrap the array as shown below. Save an empty array and a final page with a null cursor to check the display and pagination boundaries.
Match the receiver’s schema
Keep IDs as strings if the API contract uses text, even when their contents look numeric. Add explicit cases for absent properties and null values where the contract distinguishes them. For nested data, make one case with an empty object or list, then one with nested attributes that exercise the actual client rendering path.
A valid JSON file can still have an incorrect schema. Assert the expected keys and types in your test harness before using the fixture. Also check whether an import preserves Unicode and newline escapes. Choose an appropriate error response when a field type is intentionally invalid, and configure its HTTP status on the mock server.
Make failures reproducible
Set an integer seed in advanced settings before downloading the dataset. Keep the field order, locale and generator version stable, and pin the reference date when generating dates. Save the exported file with your test assets so that changes to Faker do not unexpectedly change an existing snapshot. A separate larger batch helps with performance tests, while the small fixture keeps the regression case easy to read and review.
Run the same fixture through the client’s failure view once using a deliberately mismatched content type. A JSON payload and the response metadata can fail independently.
JavaScript test example
import { readFileSync } from 'node:fs';
const items = JSON.parse(readFileSync('mock-json-data.json', 'utf8'));
if (!Array.isArray(items) || !items.every(row =>
typeof row.name === 'string' && typeof row.email === 'string'
)) throw new Error('Unexpected contact fixture');
console.log(JSON.stringify({ items, nextCursor: null }, null, 2));