Dev
Mock HTTP Response Body Generator
Building frontend features before the backend exists, writing Pact contract tests, and documenting REST API endpoints all require the same thing: a realistic JSON response body. Hand-writing these is slow and the output is usually inconsistent — missing a requestId here, wrong field name there. This generator produces correctly structured bodies for five common REST response patterns with one click. The Response Pattern selector drives the output shape. Success with data returns a resource object wrapped in a data key with a meta block containing requestId and timestamp. Paginated list wraps a ten-item array under data with a pagination object that includes total, page, perPage, totalPages, hasNext, and hasPrev — ready to test infinite scroll or page-number UI. Error response picks one of four realistic error objects (NOT_FOUND, UNAUTHORIZED, VALIDATION_ERROR, RATE_LIMITED) with code, message, status, requestId, and timestamp. Created resource mirrors a 201 response with the new resource ID, a name field, createdAt, and a message string. Auth token response produces accessToken, refreshToken, tokenType, expiresIn, and scope — suitable for seeding localStorage in Cypress or Playwright tests to skip the login flow. The Resource Name field customizes the field key inside each response: enter "order" and the data object includes an orderName field. All output is valid JSON, paste-ready for MSW, Postman, json-server, and fixture files.
How to use
- Choose your options above
- Click Generate
- Copy your result
Detailed instructions
- Select your desired response pattern from the dropdown: success with data, paginated list, error, created resource, or auth token.
- Type your resource name into the Resource Name field using a singular noun that matches your API domain (e.g. 'order', 'product').
- Click Generate to produce a valid JSON response body shaped to your chosen pattern and resource.
- Copy the output and paste it into your mock server config, test fixture file, or API documentation example.
Use Cases
- •Dropping a paginated list fixture into an MSW handler to develop infinite-scroll UI before the backend is ready
- •Pasting a generated error payload into Postman as a saved example for 404 and 422 endpoint documentation
- •Seeding Pact consumer tests with a stable auth token response body to verify front-end login logic
- •Populating Storybook stories with a realistic created-resource shape for a POST confirmation screen
- •Replacing a flaky live API call in a Jest test with a controlled success-with-data fixture
Tips
- →Use snake_case resource names like 'blog_post' or 'line_item' if your API follows Rails or Python conventions — the output keys will match.
- →Generate one of each pattern for the same resource and save them as a fixture set; this covers the main response states a component needs to handle.
- →For pagination testing, generate the paginated pattern twice with different page values and wire them to sequential requests in your mock server.
- →The auth token response works well as a localStorage seed in Cypress or Playwright tests — set it before the test runs to skip the login flow entirely.
- →When writing API docs in OpenAPI, paste the generated body into the `example` field of your response schema for instant, realistic documentation.
- →Combine the error pattern with a specific HTTP status code (422 for validation, 404 for not found) in your mock config to test how your UI handles each failure type distinctly.
FAQ
how do I use a generated JSON body in MSW
Copy the output and return it inside an MSW handler using HttpResponse.json(yourObject). The generator produces valid JSON, so you can paste it directly without transformation. Set the resource name to match your real endpoint to keep the mock consistent with the eventual API.
what fields should an API error response body include
A solid error body needs a machine-readable code (e.g. RESOURCE_NOT_FOUND), a human-readable message, the HTTP status number, and a request_id for server-side tracing. The error pattern here follows that convention so you can paste it straight into docs or test fixtures without editing the structure.
what does a paginated API response look like versus a plain success response
A plain success response returns your resource directly under a data key. A paginated response wraps the item array in an envelope with fields like total, page, perPage, totalPages, hasNext, and hasPrev. Select the paginated pattern and set your resource name to see both levels of the structure filled in with realistic values.
which response patterns does this generator support
Five patterns are available: success with data (single resource object under data with meta block), paginated list (ten-item array with pagination object), error response (four possible error codes with status and requestId), created resource (201-style response with message), and auth token response (accessToken, refreshToken, tokenType, expiresIn, scope).
You might also like
Popular tools from other categories that share themes with this one.
Try these next
More free tools from other corners of the catalog, picked by shared themes.