Mock API Response Generator
Generate mock HTTP API responses with a custom method, status code, headers, delay, and JSON, XML, or text body. Copy the full response instantly, all in your browser.
What This Mock API Response Generator Does
A mock API response is a realistic HTTP response you can hand to a frontend, a test suite, or a teammate before the real endpoint exists. This generator builds one from the parts that matter: the request method, a status code with its official reason phrase, response headers, a simulated delay, and a JSON, XML, text, or HTML body. The full wire format, status line, headers, and body, is assembled live as you edit, so you can paste it into documentation, an integration test, or a mock server config.
Everything runs in your browser. There is no server that receives your payload, which matters when the response body contains internal field names, error shapes, or contract details from an unreleased API.
How to Use It
- Pick the HTTP method and the status code you want to simulate. Common success and error codes are included with their standard reason phrases.
- Choose a content type. The body editor switches its syntax highlighting to match, and a fresh sample payload is loaded for that format.
- Edit the response body. Any valid JSON, XML, or text works; the byte count and Content-Length header update as you type.
- Add custom headers, one
Key: Valuepair per line. Headers such as Content-Type or Server override the generated defaults. - Set a simulated delay if you want to document latency behavior, then copy the full response or download it as an
.httpfile.
Response Headers Explained
The generator always includes four headers. Content-Type declares the media type of the body, with a UTF-8 charset. Content-Length is the exact size of the body in bytes, which you can verify independently because the byte count is shown above the output. Date follows the HTTP-date format from RFC 9110 (for example, Sun, 06 Nov 1994 08:49:37 GMT style). Server is a harmless placeholder identifying this tool.
When you set a simulated delay, an X-Mock-Delay header is added so the value travels with the response instead of living only in someone's notes. Custom headers are merged last and are matched case-insensitively, so a custom content-type line replaces the generated one rather than creating a duplicate.
Status Codes Worth Testing
Error paths are the reason most teams build mocks. A 400 Bad Request or 422 Unprocessable Entity response should render field-level validation messages. A 401 Unauthorized should trigger a re-authentication flow, while 403 Forbidden should show a permission message and never retry. 409 Conflict is useful for optimistic update flows, and 429 Too Many Requests pairs with a Retry-After header to test backoff logic. Server-side codes such as 500, 502, and 503 verify that your error boundary and retry UI degrade gracefully.
Note that 204 No Content and 304 Not Modified responses are defined without a body. When you pick one of those statuses, the tool omits the body from the generated response automatically.
Using Mock Responses in Development
Contract-first development works best when the mock response is written down before implementation starts. Generate the response, save the .http file or paste it into your team wiki, and agree on field names, nesting, and error shapes early. Frontends can then point their data layer at a local fixture, a service worker route, or a mock server configuration built from the same payload.
For loading and error states, generate several variants of the same endpoint: a paginated success response, an empty list, and one representative failure. Testing the empty state with real-shaped data beats discovering it in production. Pair the response shape with the Dummy JSON Generator when you need larger random datasets, and validate the finished body with the JSON Formatter.
Mock Response vs Live API
A mock defines what you expect an API to return, while a live API defines what it actually returns. Mocks keep frontend work unblocked while the backend is in progress, make tests deterministic, and let you reproduce rare responses such as timeouts or rate limits on demand. The tradeoff is drift: when the real API changes, the mock keeps happily returning the old shape. Regenerate or review mocks whenever the API contract changes, and keep at least one integration test pointed at the real service so drift is caught.
Related Tools
Look up the meaning of any code in the full HTTP Status Codes reference, decode the values you send back with the API Header Parser, format and validate the body with the JSON Formatter, or generate realistic random payloads with the Dummy JSON Generator.
Frequently Asked Questions
Does this tool send real HTTP requests?
No. It generates a response document, not a running server. Use the output as a fixture in your tests, a service worker route, a mock server config such as json-server or MSW, or documentation. The delay field documents expected latency, it does not pause anything.
Is my response body uploaded anywhere?
No. All parsing, header assembly, and output generation happen in your browser. Nothing is stored or transmitted, so proprietary field names and error shapes are safe to paste.
Why does the body disappear for some status codes?
Statuses 204 No Content and 304 Not Modified are defined by the HTTP specification to have no body. Requesting a body for them would produce an invalid response, so the generator omits it and shows a note instead.
Can I override the generated headers?
Yes. Any custom header line with the same name as a generated header replaces it, matched case-insensitively. For example, adding a Content-Type line replaces the generated one rather than duplicating it.
How is Content-Length calculated?
It counts the UTF-8 bytes of the body, not the number of characters. Multi-byte characters such as accents or emoji count as two or more bytes each, which is exactly how a real server would report the length.
What is the difference between 401 and 403?
401 Unauthorized means the request lacks valid authentication credentials and the client may retry after authenticating. 403 Forbidden means the credentials are understood but access is denied, so retrying with the same credentials will not help.
Which content types are supported?
JSON, XML, plain text, and HTML. The body editor highlights the format you pick, and you can still paste any text you like. The chosen content type is written into the Content-Type header automatically.