Dev
Mock HTTP Status Response Generator
Used by developers, writers, and creators worldwide.
A mock HTTP status response generator gives developers and QA engineers ready-made HTTP responses — complete with status lines, headers, and JSON bodies — without spinning up a live server. Building frontend error states, testing retry logic, or documenting an API shouldn't depend on real network conditions. Controlled, reproducible responses let you cover more edge cases faster. This tool spans every major HTTP status group: 2xx success codes like 200 OK and 201 Created, 3xx redirects, 4xx client errors like 401 and 404, and 5xx server errors like 503. Each response includes a realistic JSON body with error messages, request IDs, and status flags. Use the Status Group filter to restrict output — generate several 5xx responses at once when hardening fallback logic, or mix groups when writing API docs.
Loading usage…
Free forever — no account required
How to use
- Choose your options above
- Click Generate
- Copy your result
Detailed instructions
- Select a Status Group from the dropdown — choose 'Any' for a mixed set or a specific group like '4xx Client Error' to focus your test batch.
- Set the count field to how many mock responses you need, typically three to five for a test suite or one to two for documentation.
- Click Generate to produce the mock HTTP responses, each showing the status line, headers, and JSON body.
- Copy individual responses and paste the JSON body into your test fixture, mock server, or API documentation as needed.
- Regenerate as many times as needed to get varied status codes within the same group for broader test coverage.
Use Cases
- •Populating Postman mock servers with realistic 4xx and 5xx response bodies
- •Writing Jest or Vitest unit tests that assert correct handling of 401 Unauthorized
- •Seeding Storybook stories with varied HTTP error states for UI component testing
- •Generating API documentation examples covering both 2xx success and 4xx failure paths
- •Testing exponential backoff and circuit breaker logic using batches of 5xx responses
Tips
- →When testing retry logic, generate five or more 5xx responses at once to get varied codes like 500, 502, 503, and 504 in one batch.
- →Pair a generated 401 body with a 200 body to build realistic login-flow tests that cover both authenticated and unauthenticated states.
- →For API docs, always include at least one 4xx and one 5xx example alongside your 2xx success response — readers need to see failure modes.
- →The X-Request-ID in the headers is a useful field to reference in your error handling UI — show it in error messages so users can report it.
- →When using responses in Storybook, create one story per status group so each UI error state has a dedicated, reproducible example.
- →If your API uses 422 Unprocessable Entity for validation errors, filter to 4xx and look for 422 responses — their bodies typically include a field-level errors array you can adapt.
FAQ
how do I use mock HTTP responses in Jest or Vitest tests
Copy the generated JSON body and use it as the return value in a jest.fn() or vi.fn() mock for your fetch or axios calls. Set the matching status code on the mock response object. This lets you assert correct error-handling behavior without a real server or network request.
are the generated JSON response bodies realistic enough for real test suites
Yes. Success responses include a data object and status flag; error responses include an error code, human-readable message, and a request ID — matching conventions used by Express, Django REST Framework, and Spring Boot. Headers like Retry-After on 429s and Location on 3xx redirects are included where appropriate.
what is the difference between a 502 and 503 in the generated output
The generator reflects the real-world distinction: a 502 Bad Gateway body signals an upstream server returned an invalid response, while a 503 Service Unavailable body indicates the server is temporarily down and often includes a Retry-After header. This lets you test distinct fallback messages for each failure mode.