All tools

Mock API Generator

Design fake API endpoints and export fixtures, json-server or OpenAPI

Define mock endpoints with methods, paths, status codes and JSON responses, then export fixture files, a json-server db.json or an OpenAPI 3.1 document that Prism can serve.

How to use Mock API Generator

  1. Start from a sample (users, products or tasks), or press Add endpoint.
  2. For each endpoint, set the Method, Path (use :id or {id} for parameters), Status and the Response body as JSON. Problems are shown next to the field and marked “fix” in the list.
  3. Pick an export: OpenAPI YAML or JSON (serve it with Prism), or json-server db.json. Copy or download it, or download every response as Fixtures (ZIP) for your tests.
  4. Use Export project to save your endpoints as a file, and Import project to load it again. The current project is also kept in this browser.

How it works

Each endpoint is checked before anything is exported: the path must use valid characters and name each parameter once, the status must be a real HTTP status, and the body must be valid JSON. Two endpoints with the same method and a path that differs only in parameter names (/users/:id and /users/{userId}) count as the same route.

The OpenAPI 3.1 export turns :id into {id}, declares every path parameter, and uses each body as the example response, which is what Prism returns when you run prism mock openapi.yaml. The json-server export collects every GET /name endpoint that returns a list into db.json; json-server then serves list, get, create, update and delete for those collections. Fixtures are one JSON file per endpoint, named after its method, path and status.

Limits

  • This tool writes files; it doesn’t run a server or answer requests. Run Prism or json-server yourself to serve the mock.
  • One response per method and path, with a fixed body: no request matching, custom headers, delays or generated data.
  • json-server only understands collections, so endpoints other than GET /name returning a list are left out of db.json (the page says how many).
  • The OpenAPI document contains examples but no schemas, and up to 500 endpoints can be imported.

Privacy

Everything runs in your browser. Your project is saved only in this browser’s local storage, and nothing is uploaded or sent anywhere.

Frequently asked questions

How do I serve the mock API?

Download the OpenAPI file and run npx @stoplight/prism-cli mock openapi.yaml, or download db.json and run npx json-server db.json. Both start a local server you can call from your app.

Prism or json-server: which should I use?

Prism returns exactly the examples you wrote for every route and status, which suits front-end work against a fixed contract. json-server gives you a writable fake database for simple collections, so created and deleted items persist while it runs.

Where is my project stored?

In this browser’s local storage only. Use Export project to keep a copy or move it to another device; clearing site data removes it.

More tools