Skip to main content

API Mock Server Config Generator

Define your API endpoints — method, path, status, and response body — and generate ready-to-use configurations for JSON Server (db.json) or MSW TypeScript handlers. Nothing is sent to any server — runs entirely in your browser.

✓ JSON Server db.json ✓ MSW TypeScript handlers ✓ Copy to clipboard
Add Endpoint
Endpoints (0)
No endpoints added yet. Use the form above or load an example.
Output format
Generated config will appear here

Frequently Asked Questions

What is a mock server and why do I need one?▼

A mock server simulates a real API without any backend infrastructure. During frontend development, you often need API responses before the real server is ready — mock servers let you build and test UI components against predictable data. They also help QA teams write tests without hitting production databases, and let teams work in parallel without blocking on backend completion.

What is JSON Server and when should I use it?▼

JSON Server is a zero-code REST API built from a single db.json file. You run npx json-server db.json and instantly get full CRUD endpoints with filtering, sorting, and pagination. It's ideal for rapid prototyping and local development when you want real HTTP requests. The generated db.json from this tool seeds your initial data and resource structure so JSON Server knows what collections to serve.

What is MSW (Mock Service Worker)?▼

MSW intercepts network requests at the Service Worker layer in the browser (or at the Node.js http module in tests). Unlike JSON Server, MSW runs inside your app without a separate process. It's the preferred choice for component tests with Vitest or Jest, Storybook stories, and CI environments. MSW handlers are TypeScript functions that return structured responses using the http and HttpResponse API from msw v2.

What is the difference between JSON Server and MSW output?▼

JSON Server output is a db.json file — a plain object whose top-level keys become REST resource collections. GET /users returns db.json.users, POST /users appends to it, and so on. MSW output is TypeScript source code that exports a handlers array. Each handler is a function that matches method + path and returns an HttpResponse. JSON Server is a standalone dev server; MSW is a library integrated into your test or app code.

How does REST path matching work in the generated MSW handlers?▼

MSW v2 uses path patterns identical to Express-style routing. Static paths like /users match exactly. Parameterized paths like /users/:id capture the segment as request.params.id. Wildcard segments and nested paths are both supported. The generated handlers pass through request.params so you can return different response bodies based on the captured ID or other parameters.

Can I use the generated config in production?▼

No — both JSON Server and MSW are development and testing tools only. JSON Server has no auth, rate limiting, or persistence beyond the flat JSON file. MSW handlers replace real network calls, so they must be disabled before shipping. The standard pattern is to register MSW only when process.env.NODE_ENV === 'test' or when a VITE_MOCK_API flag is set, and never bundle mock handlers into your production build.

Share this tool: X / Twitter LinkedIn
✓ 60,000+ developers use DevPlaybook ★★★★★ 4.8 / 5 on Gumroad ✓ MIT licensed · Instant download ✓ No login required

Related Products

on Gumroad

You Might Also Need

More Free Tools

OpenAPI Validator API Response Mock Generator API Response Time Tester OpenAPI Schema Validator OpenAPI Mock Generator SQL to TypeScript Types API Test Case Generator TypeScript Discriminated Union Builder API Request Builder HTTP API Tester TypeScript Playground TypeScript to JavaScript Converter TypeScript tsconfig.json Generator JS Prototype Chain Visualizer Jest Testing Framework Guide Neon DB Query Builder API Rate Limit Calculator API Response Formatter & Analyzer Code Tools JavaScript Formatter & Minifier JSON to TypeScript Interface Prettier Config Generator LLM Cost Calculator AI Prompt Cost Calculator REST API Request Builder Vitest Guide — Vite-native Testing Cypress Frontend Testing Guide Pulumi Modern IaC Guide LLM Prompt Cost Calculator API Response Mocker AI Rate Limit Calculator HTML5 Canvas API Playground Zustand Store Builder GraphQL Client Configurator Axios Interceptor Builder OpenAI Function Calling Generator Jest Mock Generator Turso Edge DB Explorer API Key Generator AI Doc Generator — Pro Tool AI Unit Test Generator — Pro Tool ESLint Config Generator HTTP Methods Reference HTTP Code Snippet Generator HTTP Status Code Reference HTTP Status Code Reference Interview Question Generator JSON Diff Viewer JSON Diff Regex Visualizer Regex Tester Pro Regex Tester Rate Limiter Tester API Changelog Generator HTTP Mock Response Builder Rate Limit Calculator Biome Config Generator CORS Policy Builder Haproxy Config Validator HTTP Status Code Lookup HTTP Status Code Lookup Vue Component Generator HTTP Status Code Reference Vitest Configuration Generator LLM Context Window Calculator Regex Flags Explainer LLM Token Counter k6 Load Test Script Generator Playwright E2E Test Generator Jest Coverage Config Generator Bundle Size Estimator JavaScript Memory Leak Detector Prompt Token Estimator NPM Bundle Size Estimator Playwright E2E Testing Guide Mock Service Worker (MSW) API Mocking Guide AWS CDK Infrastructure as Code Guide JSON Schema to Zod Converter Drizzle Schema Generator Playwright Test Generator Pulumi Stack Config Generator Bundle Size Impact Calculator Game Loop Calculator Bezier Curve Editor Particle System Config Generator Prompt Injection Tester Token Context Calculator TanStack Query Config Builder SWR Config Generator Jotai Atom Explorer Token Counter & Cost Estimator AI API Rate Limit Calculator React Component Generator

Enjoying this tool? Get more like it.

Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.

DevPlaybook Pro 7 days free

Unlock AI-Powered Dev Tools

  • ⚡ AI Code Review, Doc Generator & SQL Builder
  • ⚡ All premium templates & early access
  • ⚡ Member discounts on Gumroad products
Start Free Trial →

$9/mo after trial · Cancel anytime

Want the full toolkit?

Get DevPlaybook Pro

Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.

$79
$241 separately Save $162 (67% off)
Get DevPlaybook Pro — $79 →

MIT licensed · Instant download · No subscription

See what's included → Browse all deals →