WebToolsPlanet
generator Tools

Mock API Response Generator

Generate structured mock JSON API responses from a schema — for frontend testing and component prototyping.

Last updated: March 25, 2026

Client-Side Processing
Input Data Stays on Device
Instant Local Execution

Find this tool useful? Support the project to keep it free!

Buy me a coffee

What is Mock API Response Generator?

Modern web development is highly decoupled — frontend teams and backend teams often work in parallel' on separate codebases. Frontend developers frequently need realistic API response data before the backend endpoints are built, or want to test edge cases (empty states, error responses, pagination boundaries) that would be difficult to reproduce against a live API.

A mock API response is a static JSON structure that mimics what a real backend API would return. It lets you: prototype UI components against realistic data shapes, test pagination, empty state, and error state handling, develop offline without a backend connection, and write unit tests for frontend code without mocking at the test level. This tool generates structured JSON responses based on common REST API patterns — resource objects, paginated lists, success/error envelopes — with randomized but realistic field values.

How to Use Mock API Response Generator

1

Select a response template from the dropdown: Single Resource, Paginated List, Created Resource, Error Response, or Custom Schema

2

For Paginated List: configure the number of items, page number, and total count

3

For Custom: define field names and their types (string, number, boolean, date, UUID, email)

4

Click "Generate Response" to produce a new randomized response matching the configured schema

5

Click "Regenerate" to get fresh random field values with the same structure, or "Copy JSON" to use it

Common Use Cases

  • Developing a product listing page UI before the /products endpoint exists on the backend
  • Testing empty state and zero-result UI when an API would normally return paginated data
  • Generating error response JSON (404, 422, 500) to test frontend error handling components
  • Writing unit tests for an API client module using realistic response fixtures
  • Prototyping a dashboard with multiple realistic data cards before backend integration
  • Generating fixture JSON files for Storybook stories that require specific data to render components
  • Demonstrating an API contract to a backend team during planning before implementation
  • Testing how a data table component handles 100 records, then edge-testing with 0 records

Example Input and Output

A typical paginated REST API list response with metadata:

Configuration
Template: Paginated List
Resource: User
Items per page: 3
Current page: 1
Total items: 48
Generated JSON response
{
  "data": [
    { "id": "a3f7c29e-...", "name":"Priya Nair",  "email":"priya.nair@example.com",  "createdAt":"2024-01-14T08:23:11Z" },
    { "id": "b81d4f0a-...", "name":"Luca Moretti","email":"lmoretti42@example.net", "createdAt":"2024-02-28T15:44:02Z" },
    { "id": "c52e9a7b-...", "name":"Aisha Okonkwo","email":"a.okonkwo@example.org","createdAt":"2024-03-09T11:00:55Z" }
  ],
  "pagination": {
    "page": 1,
    "perPage": 3,
    "totalItems": 48,
    "totalPages": 16,
    "hasNextPage": true,
    "hasPrevPage": false
  },
  "status": "success"
}

Client-Side Processing

All JSON generation happens in your browser. Your custom schemas and generated data are never sent to our servers. This tool works fully offline.

MSW Integration Tip

For a full mock API experience in your React/Vue app, combine this tool with Mock Service Worker (MSW). Use this generator to design your response shapes, then copy the JSON into MSW handler return values. MSW intercepts fetch() calls at the Service Worker level, requiring zero changes to your production API client code.

Storybook Fixture Tip

When writing Storybook stories, save your generated mock response as a .json fixture file (e.g. __fixtures__/users-page-1.json). Import it in your story: import userData from '../fixtures/users-page-1.json'. This makes stories declarative and self-documenting — any developer can immediately understand what data the component receives.

Frequently Asked Questions

What is the difference between a mock API and a stub API?
A mock API (this tool) generates static JSON that mimics a response — no server is running. A stub API (like json-server, Mirage.js, or MSW — Mock Service Worker) intercepts actual HTTP requests in your frontend application and returns configurable responses without hitting a real server. Use this tool for quick fixture generation; use MSW or Mirage.js for a full development mock API server.
How is this different from JSONPlaceholder.typicode.com?
JSONPlaceholder is a free online API server that always returns the same predefined data shapes (posts, users, todos). This tool generates data offline in your browser with customizable schemas, variable record counts, configurable pagination metadata, and error response simulation. It also works offline — perfect for airplane development.
Can I define my own field schema?
Yes. Use the Custom Schema tab to define field names and types. Available types include: string (random lorem word), number (integer range), decimal, boolean, date (ISO 8601), UUID, email, phone, URL, and name. The generator produces valid random values matching each type for every record in the output array.
Should I use this in unit tests or just for prototyping?
Both. For prototyping: generate, copy, and paste the JSON into your component. For unit tests: generate a fixture file once, save it to your __fixtures__ directory, and import it in your test file. Having a consistent, deterministic fixture is better for tests than generating fresh random data on every test run.
What HTTP error response formats are supported?
The tool generates common error envelope shapes: RFC 7807 (Problem Details): { "type": "...", "title": "...", "status": 422, "detail": "...", "instance": "..." }. JSON API errors: { "errors": [{ "status": "422", "source": { "pointer": "/data/attributes/email" }, "detail": "..." }] }. Simple envelope: { "success": false, "error": { "code": "VALIDATION_FAILED", "message": "..." } }.
Does the generated data use real names and emails?
No. Names are randomly selected from diverse first/last name dictionaries. Emails combine the generated name with a number and a fictional domain (@example.com, @example.net, @example.org). Per RFC 2606, the .example TLD is reserved for documentation and testing — these addresses will never resolve to real inboxes.

How This Tool Works

Selecting a template instantiates a schema configuration object defining the shape of the response. For each requested record, a generation function loops over the schema fields and calls type-specific random value generators: UUID uses crypto.randomUUID(), names are sampled from predefined arrays, dates are computed as random offsets from a reference date. The individual record objects are assembled into a paginated wrapper if applicable, then serialized using JSON.stringify() with 2-space indentation.

Technical Stack

Browser-native JavaScriptcrypto.randomUUID()Schema-driven generationClient-side only