2

Describe your data once.
Get a real API, instantly.

mockingpug turns one JSON schema into a deterministic, relational dataset, then serves it over the exact endpoints your app already calls.

mock/api/user/schema.jsonSCHEMA
{
  "amount": 1000,
  "data": {
    "id": "number.increment",
    "name": "username.FS",
    "role": "role",
    "posts": "data.blogpost"
  }
}
GET /api/user/1200 OK
{
  "id": 1,
  "name": "Elena Ruiz",
  "role": "ADMIN",
  "posts": [
    { "title": "…" },
    // 6 more, resolved live
  ]
}
First step

Describe

One JSON file per entity. Field-level relations (data.user.id) and inverse relations resolve automatically.

// mock/data/role.json: a weighted custom dictionary [ { "value": "ADMIN", "max": 5 }, { "value": "USER", "chance": 0.9 } ]
Second step

Generate

Validate before anything runs, then generate a fully relational, deterministic dataset from your seed.

$ npx mpug doctor [mockingpug] 2 entities validated OK $ npx mpug generate [mockingpug] user: generated (1000 records)
Third step

Serve

Pick a transport. Same schema, same generated data, same queryresolver underneath, whether that's React (MSW) or Next.js (a real Route Handler).

// app/api/[[...mock]]/route.ts import { createNextHandlers, getMockContext } from 'mockingpug/next'; const handlers = getMockContext(process.cwd()) .then(({ ctx }) => createNextHandlers(ctx));
Under the hood

Some features

--seed

Every value is a pure function of seed + entity + index + field. Same seed, same dataset, on every machine and every run.

--relations

Field-level (data.user.id) and inverse (data.blogpost) relations resolve automatically, with cycle detection at validation time.

--reconcile

Change one field on a 10,000-record entity and only that field regenerates. Manual test mutations survive.

--rest

Pagination (page / offset / cursor), field filtering, substring search, sorting, full CRUD, and consistent error shapes, generated per entity instead of hand-wired.

--chaos

runtime.delay / runtime.errorRate inject latency and failures live, from a devtools panel, so you can test your loading and error states on demand.

--types

mockingpug types emits a .d.ts straight from your schema, so there are no hand-duplicated interfaces to drift out of sync.

--devtools

Toggle mock/real network, inspect and reset records per entity, bypass a single endpoint once its real backend is ready.

--ci

doctor --strict and --assert-prod-safe catch broken schemas and leaked mock code before they ship.

RUNS WHEREVER YOUR APP DOES
React via MSWNext.js App RouterVite auto-discoveryCLI standalone
<MockDevtools/>

A handy debugging tool

Devtools helps you visually locate mock data on a page by hiding it with asterisks ***. You can easily view each individual mock data model and add response delays or error rates to requests.

NAMEElena Ruiz
ROLEADMIN
EMAILelena.492@gmail.com
Page title (hardcoded)User Profile
Mascot

This is Morty, my pug

I named this library in his honor

mockingpug
Get started

Mock data easy

$ npm install mockingpug