HTTP Mock Builder
Define a mock HTTP endpoint and generate ready-to-use code for Express.js, MSW, or JSON Server.
mondaytool.com/tools/http-mock-builder ·
Made with MondayTool · mondaytool.com/tools/http-mock-builder
Last updated:
Generate mock API code in seconds
This HTTP mock builder turns one endpoint definition into ready-to-paste mock code for Express.js, Mock Service Worker (MSW) or JSON Server. You pick the method, path, status code, headers, JSON body and an optional delay, and the tool writes the route for you. It is handy when the real backend is not ready yet, or when you need a predictable response for tests and demos. The tool only generates code. It does not host a mock server, so you run the code in your own project.
How to use it
- Choose a method: GET, POST, PUT, PATCH or DELETE.
- Enter the path, such as
/api/users/:id, the status code and a delay in milliseconds (0 for none). - Edit the response headers.
Content-Type: application/jsonis added by default. Use + Add header or the ✕ button to change the list. - Type the response body as JSON. Click Format JSON to tidy it and catch syntax errors.
- Click Generate Code, pick a tab, then click Copy.
How it works
| Tab | What you get |
|---|---|
| Express.js | An app.get(...) style route that sets your headers and calls res.status(code).json(body). A delay wraps it in setTimeout. |
| MSW | An http.get(...) handler using HttpResponse.json with your status and headers. A delay adds await delay(ms). |
| JSON Server | A db.json file plus a start command. Method, status, headers and delay are not used here. |
For JSON Server, the resource name comes from the first part of the path. A JSON array is used as is. A single object is wrapped in an array and given id: 1 unless it already has an id. Everything runs in your browser. Nothing is sent to a server.
Tips
- The output updates when you click Generate Code or switch tabs. Click again after you change the form.
- If the body is not valid JSON, the Express and MSW code fall back to
{}. Use Format JSON first. - For JSON Server, use a short path like
/users. With/api/users/:idthe resource would be namedapi. - The Express code is a single route. Paste it into an app where
appis already created. Add the MSW handler to your handlers list.
Frequently asked questions
Does this tool host a live mock API?
No. It writes code you can paste into your own Express app, MSW setup or JSON Server folder. You run that code locally or in your test environment.
Which MSW version does the code target?
The handler imports http and HttpResponse from msw, which is the API used by MSW 2.x. Older 1.x projects use rest and ctx instead.
Can I simulate a slow or failing endpoint?
Yes. Set a delay in milliseconds to slow the response, and set a status code such as 404 or 500 to test error handling in your app.
Related Developer Tools
Browse all tools from the same category.
Domain Authority Checker
Check Moz authority, page authority, spam score, and backlink metrics
Open toolSEO Audit Tool
Audit a website URL for technical SEO, metadata, headings, broken internal links, hreflang, canonical and X-Robots-Tag checks, with report exports
Open toolShowing 1-2 of 49