API Response Mocker

Quick Presets:

Response Builder

Generated Code

// Mock fetch function for testing
const mockFetch = async (url, options) => {
  // Simulate network delay
  // No delay configured

  return {
    ok: true,
    status: 200,
    statusText: "OK",
    headers: new Headers({
      "Content-Type": "application/json"
}),
    json: async () => {
  "success": true,
  "message": "Hello World"
},
  };
};

// Usage
const response = await mockFetch("/api/endpoint");
const data = await response.json();
console.log(data);

How to use

Build Response

Define your mock API response with status code, headers, JSON body, and optional delay.

Generate Code

Get instant code snippets for fetch mocks, MSW handlers, Express routes, curl commands, and Python tests.

Test Anywhere

Copy the generated code directly into your tests or development environment. No server required.

What This Tool Does

API Response Mocker is built for deterministic developer and agent workflows.

Generate mock API responses for testing. Get instant code snippets for fetch, MSW, Express, curl, and Python. Perfect for building agent tools without spinning up a server.

Use How to Use for execution steps and FAQ for constraints, policies, and edge cases.

Last updated:

This tool is provided as-is for convenience. Output should be verified before use in any production or critical context.

Agent Invocation

Best Path For Builders

Dedicated API endpoint

Deterministic outputs, machine-safe contracts, and production-ready examples.

Dedicated API

https://aidevhub.io/api/api-response-mocker/

OpenAPI: https://aidevhub.io/api/openapi.yaml

GET /api/api-response-mocker/ GET api-response-mocker
POST /api/api-response-mocker/ POST api-response-mocker

Unified Runtime API

https://aidevhub.io/api/tools/run/?toolId=api-response-mocker&a=...

GET and POST are supported at /api/tools/run/ with identical validation and limits.

Limit: req / s, input max 128 KB.

How to Use API Response Mocker

  1. 1

    Generate mock API responses for frontend testing

    Define endpoint path, HTTP method, and shape (e.g., { id, name, email, created_at }). The tool generates realistic mock data (UUIDs for IDs, faker names/emails). Use in Storybook or Jest tests.

  2. 2

    Create paginated response mocks for list endpoints

    Configure mock for GET /users with 50 items per page. Set 'is_paginated' and specify page count. Generate paginated responses for testing pagination UI without hitting a real API.

  3. 3

    Mock error responses for failure scenarios

    Create 400, 401, 403, 500 responses with realistic error messages. Test error handling in your app without breaking the real API. Useful for negative test cases.

  4. 4

    Use mocked responses in Cypress/Playwright tests

    Generate mock response JSON, intercept the actual API call in your test (cy.intercept or page.route), and return the mocked data. App thinks it got real data, tests run fast and deterministic.

  5. 5

    Export mock data as JSON seed files

    Generate multiple mock records (e.g., 10 users), export as JSON, save to fixtures/users.json. Seed your test database or Storybook data with consistent, realistic mock data.

Frequently Asked Questions

What is API Response Mocker?
API Response Mocker generates mock API responses for testing without spinning up a server. It produces ready-to-use code for fetch, MSW, Express, cURL, and Python.
How do I use API Response Mocker?
Define your API endpoint, status code, headers, and JSON response body. The tool generates mock code in multiple formats — copy the snippet for your testing framework or language of choice.
Is API Response Mocker free?
Yes. This tool is free to use with immediate access—no account required.
Does API Response Mocker store or send my data?
No. All processing happens entirely in your browser. Your API definitions stay on your device — nothing is sent to any server.
What mock code formats does API Response Mocker support?
It generates code for JavaScript fetch, MSW (Mock Service Worker), Express.js routes, cURL commands, and Python. Each output is ready to paste directly into your project or terminal.