REST API Mock Generator

The backend team is three sprints out and your list view has nothing to render. Describe the endpoints you were promised, shape the JSON they will send back, fill it with 200 plausible records, and hand your frontend something to bind against today. Export lands as an OpenAPI 3.0 file.

Build order

Describe the service

These four fields become the info and servers blocks of the spec. Point the base URL at wherever the real service will live, so swapping the mock out later is a one-line change in your client.

Writes a matching securitySchemes entry. Individual operations stay unguarded in the export, so add the security requirement yourself if a validator asks for it.
openapi.json
Configure basics and add endpoints, then click Generate API.

Three sample endpoints are loaded. Press Generate API to see the spec.

A mock buys your frontend three weeks it would otherwise spend waiting

The pattern repeats on most teams. The API contract is agreed in a meeting, the backend starts on the hard parts, and the frontend sits with a design that has nowhere to pull data from. Hardcoding an array inside the component feels quick, then someone ships it, and six months later a fixture nobody remembers is still shadowing a real endpoint.

A mock spec keeps the fake data outside your source tree. You describe the shape once, feed it to a mock server or your test suite, and delete one file when the real service arrives. Your components never learn that the data was invented.

From this page to a running server

Nothing on this page serves traffic. It writes the description, and a separate tool serves it. Three routes work with the file the Download button gives you.

  1. Prism

    Install @stoplight/prism-cli, then run prism mock openapi.json. You get a local server on port 4010 that answers every path in the file with an example matching the declared status code.

  2. json-server

    Take the generated record array instead of the spec, save it as db.json, and run json-server db.json. You lose the path definitions, you gain working POST and PATCH against an in-memory store.

  3. MSW

    Paste the record array into a Mock Service Worker handler. The interception happens inside the browser, which keeps the mock working in your test runner and in the dev server without a second process to start.

What the four steps actually control

StepWhere it lands in the exportWhat it changes downstream
Name, version, descriptioninfoHeader text in Swagger UI. Version strings also drive client generator package names.
Base URLservers[0].urlThe host your generated client calls. Wrong value here means a mock that works and a build that does not.
Path and methodpathsAdding the same path twice with different verbs merges them under one path object, which is correct OpenAPI.
Status coderesponsesEach endpoint carries exactly one code. Add the same path and verb again to describe a second outcome.
Response formatcontent media typeSwitches between application/json, application/xml and application/text across every operation at once.
Authenticationcomponents.securitySchemesDefines the scheme. It does not apply it, so operations stay open until you attach a security block.

Placeholders the record generator understands

The schema box takes flat JSON. Any string value holding a recognised token is replaced per record. Anything else is copied through as a literal, which is how you pin a field to a fixed value.

TokenWhat each record getsGood fit for
{{faker.datatype.number}}Integer between 1 and 1000, redrawn per recordids, counts, quantities
{{faker.name.fullName}}One of five names, cycled in orderdisplay names in a list view
{{faker.internet.email}}user0@gmail.com upward, domain rotates through fouraccount rows, login tables
{{faker.image.avatar}}A pravatar.cc URL, image 1 to 50real images in a card grid
{{faker.date.recent}}ISO 8601 timestamp inside the last 30 dayscreated_at, last_seen, sort keys
{{random.number(1, 1000)}}Integer between 1 and 1000. The arguments are decorativescores, view counts
{{random.words(2)}}The string Item followed by the row indextitles you plan to overwrite
{{random.email}}user0@test.com upwardthrowaway addresses
{{random.float(0, 100)}}Two decimal places, delivered as a stringprices and ratings, once you parse it
{{random.boolean}}true or false, near even splitflags, toggles, filter tests

Matching is by substring, so a value like "Order {{faker.datatype.number}}" returns the bare number, not the sentence. Put the token on its own and build the label in your component.

Four ways mock data lies to you

Every mock is an opinion about the real service. These are the four disagreements that reach production most often.

Everything is the happy path
Ten tidy records, every field populated, no timeouts. Add a second entry for the same path with a 500 status and point your client at it for an afternoon. Empty states and error states are where mocked frontends fall over first.
Strings that are always short
Generated names run to a dozen characters. Real users have hyphenated surnames, no surname, and emoji in the display field. Paste one 200 character string into the record set on purpose and see what your layout does.
Types that drift
The float placeholder returns "42.19" with quotes around it. If the real API sends a number, your client works against the mock and breaks against the service. Check every numeric field for quotes before you build arithmetic on it.
Ten rows instead of ten thousand
Pagination bugs hide behind a single page of results. Set the record count to 500 and confirm the list virtualises, the meta block adds up, and the page-two request goes out.

Where this page stops

Worth knowing before you plan a workflow around it.

For a spec you intend to publish rather than mock against, start from the OpenAPI Swagger generator, which carries schema definitions and request bodies.

Nothing you type leaves the tab

Generation happens in JavaScript on your machine. Internal hostnames, unreleased route names and client identifiers stay in the browser, and no request carries them anywhere. Values persist until you reload the page, so refresh before handing the screen to someone else.

Questions about mocking a REST API

Serving the output, matching the real contract, and where the generator stops short.

Does this tool host a live mock endpoint I can call?

No. It writes an OpenAPI 3.0 description and a record set. Feed the spec to Prism with prism mock openapi.json for a local server, or paste the records into Mock Service Worker to intercept requests inside the browser.

Will the exported file pass an OpenAPI validator?

It parses as valid OpenAPI 3.0, but strict linters flag two things: path parameters such as {id} appear in the path without a matching parameters entry, and POST or PUT operations carry no requestBody. Both take a minute to add by hand.

How do I describe both a success and an error response for one route?

Add the endpoint twice with the same path and method, once with 200 and once with 500. Each entry writes its own response object under that operation.

Can I use nested objects in the record schema?

The generator walks top-level keys only. A nested object or array is copied into every record exactly as typed, so placeholders inside it stay as literal text. Generate flat records here, then reshape them in your editor.

Why is my number field wrapped in quotes?

The float placeholder returns a fixed-decimal string and any unrecognised token falls back to the text generated_value. Only the integer placeholders emit real JSON numbers. Strip the quotes in the response body before you build arithmetic against the mock.

Does the locale setting change the generated names?

No. It is recorded for your own reference. Names, emails and dates come from the same Latin-alphabet pool whichever locale you select, so pick a real internationalisation fixture if you are testing text direction or character width.

How many records is it safe to generate?

The counter accepts up to 1000. A thousand rows with five fields lands near 200 KB of JSON, which the browser handles without complaint. Past that, generate a smaller set and repeat it in your mock server.

What is the difference between this and the OpenAPI Swagger generator?

This page is built around getting fake data in front of a frontend fast. The OpenAPI generator is built around the contract itself, with schema definitions, request bodies and per-operation detail. Use this one to unblock a build, that one to publish a spec.