API Mock Generator
Generate MSW, json-server, Nock, Express, or fetch mocks from a JSON Schema or example — schema-aware, with an optional seed for reproducible data and a live preview.
About this ToolHow it works, benefits & use casesTap to collapse
The API Mock Generator turns a description of your endpoints into ready-to-run mock code for the framework you actually use. Define each endpoint with a method, path and record count, then choose how the data is shaped: Auto mode invents smart field values from the property name (an "email" field becomes a real-looking address, "createdAt" becomes an ISO date, "id" becomes a number), or you can drive generation from a JSON Schema (honouring type, enum, format, minimum/maximum and minItems/maxItems) or from a single JSON example whose shape is inferred and repeated. Export the result as MSW handlers, a json-server db.json, Nock interceptors, an Express server, a drop-in window.fetch mock, or raw JSON. Set a seed for byte-for-byte reproducible data, or leave it blank for fresh records each run. Everything previews live and runs entirely in the browser.
How to Use
- 1Pick a Target framework (MSW, json-server, Nock, Express, fetch mock, or raw JSON) and set the Base URL.
- 2Add endpoints with the "Add endpoint" button — for each one choose the Method, Path and Record count (1–1000).
- 3Choose a Data source: Auto for name-based smart fields, From JSON Schema, or From JSON example, then paste your schema or sample object.
- 4Optionally type a Seed for reproducible output (or click the dice to randomize); leave it blank for fresh data every run.
- 5Press "Generate mock setup" and copy, download, or pipe the generated code — the file name and MIME type match the chosen framework.
Key Benefits
- Generates real mock code for MSW, json-server, Nock, Express, fetch, or raw JSON — not just sample data
- Three data sources: name-based auto fields, JSON Schema, or an inferred JSON example
- Schema-aware: respects type, enum, format (email/uuid/date-time…), min/max and array bounds
- Optional seed produces identical, reproducible output across runs and machines
- Per-endpoint method, path and record count, with multiple endpoints in one setup
- Live preview plus a stats bar showing endpoint count, total records and byte size
- Runs fully in the browser — your schema and data never leave the page
Common Use Cases
- Standing up MSW handlers so a frontend can develop against an API that does not exist yet
- Seeding a json-server db.json for a quick prototyping backend
- Generating Nock interceptors or a fetch mock for deterministic unit tests via a fixed seed
- Producing a throwaway Express mock server for a demo or integration spike
- Turning one real example response into hundreds of varied records for load or UI testing
Mock settings
Fresh data each run
Endpoints
Endpoint 1
Fix the input to preview.
Run to generate your mock setup.
Was this tool helpful?
Share Your Experience
Help others discover this tool!
Related tools
- JSON FormatterFormat and validate JSON with syntax highlighting
- TypeScript FormatterFormat and beautify TypeScript code
- Changelog GeneratorGenerate changelog from Git commit history
- Component Name GeneratorTurn a description into ranked, kind-aware component names with a file scaffold and a name validator (casing, collisions, clarity)
- Heroku Procfile GeneratorBuild a Heroku Procfile and matching app.json — process types, env vars, addons, dyno formation — plus a Procfile parser and audit
- Markdown TOC GeneratorGenerate table of contents for Markdown
Auto invents values from each field name — "email", "createdAt", "price", "id" and many others map to realistic types. JSON Schema generates data that obeys your schema, including type, enum, format, minimum/maximum and minItems/maxItems. JSON example infers a schema from one sample object you paste and reproduces that shape N times per endpoint.
The rich generator uses a seedable mulberry32 PRNG and a fixed reference date, so the same seed, endpoints and schema always produce byte-for-byte identical code. Leave the Seed field blank to get fresh random data on every run, which is useful for varied fixtures.

