Prompt
API mock server for local development
Latest observation
Nov 19, 2026
OpenAI APIWeb search: off
Here’s a simple, practical way to set up an API mock server for local development.
Good options
1. JSON Server — fastest for REST APIs
If you want a quick mock REST API from a JSON file:
npm install -g json-server
Create db.json:
{
"users": [
{ "id": 1, "name": "Alice" },
{ "id": 2, "name": "Bob" }
]
}
Run it:
json-server --watch db.json --port 3001
Example endpoints:
GET /usersGET /users/1POST /usersPUT /users/1DELETE /users/1
2. Mock Service Worker (MSW) — best for frontend apps
If you want to mock API calls in your browser or tests without changing backend code:
npm install msw --save-dev
Use it to intercept requests in the browser or Node test environment. Great for:
- React/Vue/Angular local dev
- Unit/integration tests
- Mocking specific responses and delays
3. Express mock server — most flexible
If you want custom behavior, create a small Node server with Express:
npm install express cors
Example server.js:
const express = require('express');
const cors = require('cors');
const app = express();
app.use(cors());
app.use(express.json());
app.get('/api/users', (req, res) => {
res.json([
{ id: 1, name: 'Alice' },
{ id: 2, name: 'Bob' }
]);
});
app.listen(3001, () => {
console.log('Mock API running on http://localhost:3001');
});
Run:
node server.js
4. Mockoon — no-code GUI tool
If you want a graphical interface:
- Create endpoints visually
- Simulate delays, status codes, errors
- Export a local server or use desktop app
Great for quick team collaboration.
Recommended choice
- Simple REST CRUD mock → JSON Server
- Frontend-only mocking → MSW
- Custom logic / auth / branching responses → Express mock server
- Non-technical setup → Mockoon
If you want, I can generate a ready-to-run mock server for:
- Node/Express
- JSON Server
- OpenAPI-based mock
- Dockerized mock server