Skip to content
OpenAPI 3 → runnable mock · Express · json-server · Prism

API Mock Server Generator

Paste an OpenAPI 3 document and get a runnable mock server in seconds — one route per operation, realistic example responses synthesized from each response schema, in Express, json-server or Stoplight Prism. Generated entirely in your browser.

01 · Paste your OpenAPI 3 document
3 operations · 2 schemas · 2 paths
Generated mock server
server.js · Express
// Generated mock server — Express (Node.js)
// Run: npm i express && node server.js
const express = require("express")
const app = express()
app.use(express.json())

// GET /pets — List all pets
app.get("/pets", (req, res) => {
  res.status(200).json([
    {
      "id": 1,
      "name": "string",
      "tag": "string",
      "status": "available",
      "createdAt": "2026-01-01T00:00:00Z"
    }
  ])
})

// POST /pets — Create a pet
app.post("/pets", (req, res) => {
  res.status(201).json({
    "id": 1,
    "name": "string",
    "tag": "string",
    "status": "available",
    "createdAt": "2026-01-01T00:00:00Z"
  })
})

// GET /pets/{petId} — Get a pet by id
app.get("/pets/:petId", (req, res) => {
  res.status(200).json({
    "id": 1,
    "name": "string",
    "tag": "string",
    "status": "available",
    "createdAt": "2026-01-01T00:00:00Z"
  })
})

const PORT = process.env.PORT || 4010
app.listen(PORT, () => console.log(`Mock server running on http://localhost:${PORT}`))
Route table
MethodPathStatusExample
GET/pets200134 B
POST/pets201116 B
GET/pets/{petId}200116 B
Response preview · GET /pets
[
  {
    "id": 1,
    "name": "string",
    "tag": "string",
    "status": "available",
    "createdAt": "2026-01-01T00:00:00Z"
  }
]
Field notes

Why mock from the contract, not by hand

A mock server is the cheapest way to unblock the people who consume an API before the API exists. Frontend, mobile and integration engineers can build against realistic responses while the backend is still being written; QA can pin down deterministic edge cases; and a demo can run without a live database. The failure mode is hand-written stubs that drift away from what the real service returns — the mock says one thing, production says another, and the bug only surfaces at integration. Generating the mock from your OpenAPI document keeps the stand-in and the contract in lockstep by construction.

That is the essence of contract-first development: the OpenAPI document is the single source of truth, agreed before code is written. Both sides build against it in parallel — the backend implements it, the frontend mocks it — and because they share one artifact, they meet in the middle without surprises. This tool reads each operation's success response, follows local $ref pointers into components/schemas, and emits a route that returns a body shaped exactly like the contract promises, with the declared status code. When the contract changes, regenerate the mock and the drift is gone.

The interesting work is example synthesis. A schema describes the shape of a response, not a concrete value, so the generator has to invent a plausible instance. It prefers whatever the author already declared — an example, a default, the first enum value — and only falls back to a type- and format-aware placeholder when nothing better exists. A format: date-time string becomes an ISO timestamp, a uuid becomes a canonical UUID, and nested objects and arrays are built recursively. The result is a body you can actually render in a UI, not a wall of empty strings — the same approach the JSON Schema Explorer uses to produce conforming samples.

Three targets cover three habits. Express gives you a plain Node file you can edit and commit; json-server gives you a stateful fake REST API in one command; Stoplight Prism reads the spec directly and can serve dynamic, validated mocks that track the document automatically. Pick whichever fits the moment — and when you want to see the request/response surface laid out visually before you mock it, the REST endpoint visualizer maps the whole spec at a glance. Everything here runs in your browser, so even an unreleased internal spec never leaves your machine.

API Mock Server FAQs

Have more questions? Contact us

Trusted by Frontend & Full-stack Engineers

4.7
Based on 1,180 reviews

I pasted our checkout API's OpenAPI doc and had an Express mock running before the backend team had even merged their branch. The synthesized responses honoured our enums and date-time formats, so the UI looked real immediately. Resolving the $refs into components/schemas is the part most tools get wrong.

D
Daniel Okoro
Frontend engineer
June 12, 2026

The three targets are genuinely useful — I use json-server for quick CRUD prototypes and copy the Prism command when I want the mock to stay faithful to the spec. The route table with example sizes is a nice touch for spotting an endpoint that's accidentally returning an empty body.

M
Mei Lin
Full-stack developer
May 21, 2026

Great for standing up deterministic responses in CI before the real service is ready. The endpoint preview lets me confirm exactly what shape a test will see. I'd love per-status-code mocks for error testing, but for the happy path it's already saved us a lot of hand-written stubs.

T
Tomás Herrera
QA automation lead
April 18, 2026

Contract-first is our whole workflow, and this slots right in: same OpenAPI document, instant mock, nothing leaves the browser so I can do it with unreleased specs. The Express output is clean enough that I just commit it and tweak a couple of responses by hand.

S
Saanvi Rao
API platform engineer
March 9, 2026

Love using our calculator?

Connected instruments

Related API tools

Learn More

Related Articles

Dive deeper with our expert guides and tutorials related to API Mock Server Generator

Loading articles...

OpenAPI 3 → Express · json-server · Prism · in-browser · Last reviewed: 2026-06