Mock API response generator
Generate a complete mock HTTP response: pick the status code, method and Content-Type, build the body from a field list or a JSON Schema, optionally wrap it in pagination or an RFC 7807 error structure, and get the full status line + headers + body message.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
Request settings
Values are deterministic: the same settings always produce the same response, so you can paste it straight into assertions or docs.
Response body source
Wrappers
Full response
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Content-Length: 92
X-Mock-Method: GET
{
"id": 995,
"name": "bravo",
"role": "admin",
"createdAt": "2026-10-10T11:30:00Z"
}{
"id": 995,
"name": "bravo",
"role": "admin",
"createdAt": "2026-10-10T11:30:00Z"
}What this tool does
- Get a structurally complete example response for your API docs: status line, Content-Type, Content-Length and pretty-printed JSON body, ready to paste into a README.
- Build mocks before the backend exists: generate a body from a field list or a JSON Schema, switch on pagination for list endpoints, switch on the error structure for RFC 7807 problem+json.
- Design one error shape for every status code with RFC 7807’s type / title / status / detail / instance, instead of a different format per endpoint.
- Check how Content-Length is really computed: it counts UTF-8 bytes, so a Chinese character costs three — not the number of characters.
Example
Input
Status 404, method GET, “Error structure (RFC 7807)” on, detail=User not found, instance=/api/users/42
Output
HTTP/1.1 404 Not Found
Content-Type: application/problem+json; charset=utf-8
Content-Length: 129
X-Mock-Method: GET
{
"type": "about:blank",
"title": "Not Found",
"status": 404,
"detail": "User not found",
"instance": "/api/users/42"
}Turning on the error structure switches Content-Type to application/problem+json automatically, and an empty type becomes about:blank as RFC 7807 prescribes. Messages use CRLF line endings, exactly like real HTTP.
Frequently asked questions
Is the generated body random?
No. Numeric values come from a deterministic generator (mulberry32) seeded with the field list or schema text, so the same settings always produce the same response — you can paste it straight into an assertion. Strings and dates are picked by field index, with dates counting from 2026-10-10.
How much JSON Schema is supported?
The tool reads type, properties, items, enum, const, default, example, format, minimum, maximum, multipleOf, minItems and maxItems. Documentation-only keywords such as description or title are ignored silently, while unimplemented ones such as $ref, oneOf or pattern are listed above the result instead of being quietly dropped.
Why are X-Mock-Delay and X-Mock-Method in the headers?
They are not standard headers, just hints for a mock server or a reader: the delay says how slow this endpoint should be, the method says which request method the response is for. Real HTTP clients ignore them.
Why does Content-Length not match the character count?
Because Content-Length counts bytes: one byte per ASCII character, three per Chinese character. The tool measures the UTF-8 length with TextEncoder, which is exactly the mistake hand-written mocks tend to make.
Can a custom header override Content-Type?
No. Content-Type and Content-Length are derived from your settings and the body, and passing either name in the extra headers raises an error — that keeps the message from claiming JSON while carrying something else.
Keywords:api responsemock apihttp responsejson schema mockrfc 7807接口响应Mock 响应HTTP 响应示例problem+json分页响应