API Mock Server Generator

One file, no dependencies.

Sketch the API your front end needs before the backend exists. Define each endpoint and its response, add realistic latency, and copy a mock server that runs with plain node and nothing to install.

Zero retention: your data never leaves this browser. Verify it yourself in DevTools

Loading the toolbox.

About API mock

How Can You Verify That Nothing Leaves This Browser?

You do not have to take our word that your data stays here. Developer tools show every request a page makes, so you can watch this page work and confirm that nothing is sent. The check takes under a minute.

  1. Open your browser developer tools with F12, or Cmd+Option+I on a Mac, and select the Network tab.
  2. Reload the page and let it finish. You will see the page's own files, its web fonts, and one anonymous page-view request. Nothing has been typed yet, so none of them can contain your data.
  3. Click the clear icon in the Network tab so that the log is empty.
  4. Use the tool with your own input.
  5. Look at the Network tab again. It is still empty. For extra proof, turn on offline mode after the page loads and the tool keeps working.

Only two things can add a line to that log, and neither carries your data. Submitting the feedback form sends the vote and comment you typed. Typing characters in a script the page has not displayed yet, such as Cyrillic or Greek, can make the browser fetch the matching font file, and that request names only the font.

The production site also sends a Content-Security-Policy header that tells your browser to refuse connections to anywhere except this site and the anonymous analytics endpoint, so a coding mistake could not quietly send your data elsewhere.

What Does API mock Generate?

API mock writes two files from the endpoints you define. The first is mock-server.mjs, a single JavaScript module that uses only the node:http module that ships with Node. It needs no npm install, no framework, and no configuration file: save it anywhere and run node mock-server.mjs. The second is mocks.json, a fixture keyed by method and path that holds each status code, header set, delay, and body, ready for a test runner or another mock tool to read.

The server answers each defined route with the exact status, headers, and JSON you set, returns a JSON 404 for anything else, and answers CORS preflight requests so a front end on another port can call it during development.

How Do You Define Endpoints and Responses?

  • Method and path: GET, POST, PUT, DELETE, or PATCH, with a path such as /api/users/:id. A segment that starts with a colon matches any value.
  • Status code: one click for 200, 201, 400, 401, 403, 404, 429, or 500, or type any custom code from 100 to 599.
  • Headers: one Name: value per line, checked for valid names and printable values. Use them for Location, Retry-After, Cache-Control, or a request ID.
  • JSON body: validated as you type, with the line and column of the first error. Leave it empty for a response with no body.

Every endpoint is listed with its route, status, and delay, and any endpoint with a problem is flagged so a typo never slips into the generated server unnoticed. Duplicate routes are called out too, because only the first one can ever answer.

How Does Schema-From-Example Work?

Paste a real response from an API you already have, and API mock infers a JSON Schema from it. Integers and decimals are told apart, nested objects and arrays are followed all the way down, and strings that look like dates, timestamps, email addresses, URLs, or UUIDs get a matching format. Array items are merged, so a key that appears in only some items is listed as a property but not as required.

From the same example it builds mock variants you can drop into any endpoint with one click:

  • An array of N items, with ids counting up, dates moving forward a day at a time, and emails kept unique.
  • An all-null copy that keeps the shape, for testing how the interface handles missing data.
  • Edge cases: empty strings and zeros, empty arrays, very large numbers and 1,024-character strings, negative numbers, and strings full of quotes, markup, accented letters, and emoji.

Why Simulate Latency in a Mock API?

A mock that answers instantly hides real problems. Loading spinners never appear, double submissions go unnoticed, and race conditions between requests never show up. Give each endpoint its own delay in milliseconds and the generated server waits that long before it responds, so you can see the interface exactly as a user on a slow connection would.

Pair a delay with a 429 status and a Retry-After header to test back-off logic, or with a 500 to check that error states render properly after a pause rather than flashing past.

When Should You Use a Mock Server?

  • Building a front end while the backend is still being written.
  • Reproducing an error response that is hard to trigger against the real service.
  • Running demos and end-to-end tests that must not depend on a network or a shared staging server.
  • Agreeing on a response shape with another team before either side writes code.

The generated server is meant for development and testing. It holds every response in memory, never changes state between requests, and should not face the public internet.

What Other Tools Are in the Generators Lane?

  • UUID: UUID v4 and v7, ULID, and NanoID in bulk, plus a decoder that reads timestamps back out.
  • .gitignore: Pick your languages, frameworks, OS, and editor; get one merged, de-duplicated .gitignore.
  • CSP: Build a Content-Security-Policy header or meta tag, with nonces, hashes, strict-dynamic, and Report-Only.
  • .htaccess: Apache rules for HTTPS, www canonical, compression, caching, headers, file blocking, and SPA fallback.
  • robots.txt: A robots.txt with your sitemap, private paths, crawl delay, and plain-English notes.
  • Meeting notes: Paste raw meeting notes; get actions, decisions, and open questions with an owner for each, as Markdown, JSON, or CSV.

Elsewhere in the toolbox: Hash, Base, TOTP, XML, and more on the 2toolbox home page. Part of the 2suite.io privacy-first ecosystem.

Frequently Asked Questions

Does the generated mock server need any packages?

No. It imports only node:http, which is built into Node 18 and newer, so it runs with node mock-server.mjs and no install step.

How do path parameters work?

Write a segment that starts with a colon, such as /api/users/:id. It matches any single path segment, so /api/users/7 and /api/users/abc both get that response.

Is my API data uploaded anywhere?

No. Endpoints, bodies, and samples stay in this tab, are never saved, and the page makes no request while you work.

Why is the file .mjs?

The .mjs extension tells Node to load it as an ES module whatever your package.json says, so the import line works in any project.

Was this helpful?