GenerateRandomSearch

Mock API Error Generator

Generates a sample JSON error-response payload — code, message and status together — for testing how your client handles a failed API call, not just a successful one.

What this generator does

Fills one of two JSON error-shape templates by combining a fixed error code, a fixed message and a fixed HTTP status drawn independently, so the code, message and status you see together are one random combination among the shape's possibilities rather than a hand-picked matching set.

What it builds, and how many ways

Each result is assembled to this shape: [error code] + [error message] + [status] — one of 2 sentence patterns this generator uses.

  • error code: 7 options
  • error message: 7 options
  • status: 7 options

Taken together those banks can be assembled 686 different ways, repeating after about 33.

Some results it can produce:

  • { "error": { "code": "VALIDATION_FAILED", "message": "The request payload failed validation.", "status": 400 } }
  • { "success": false, "error": "The resource already exists.", "code": "NOT_FOUND", "statusCode": 422 }
  • { "error": { "code": "RATE_LIMITED", "message": "Authentication credentials were missing or invalid.", "status": 401 } }
  • { "success": false, "error": "The requested resource could not be found.", "code": "RATE_LIMITED", "statusCode": 429 }

A fixed sample so this page stays the same between visits. Your own results are assembled at random, each slot filled independently and each press independent of the last, so the same result can come up twice — past the repeat figure above, seeing one twice is more likely than not.

How to use this tool

  1. Press generate for an error payload.
  2. Copy it, or generate again for another one.

Common use cases

  • Testing error-handling UI
  • Mock-server fixture data
  • API-client error-path tests

Limitations and good to know

  • Fields are drawn independently, so the generated code, message and status are not guaranteed to be semantically consistent with each other the way a real error response is — check the combination rather than assuming it's realistic.
  • Only two response shapes and a fixed set of 7 codes, messages and statuses — a small, illustrative combinatorial space rather than a match for any specific API's actual error contract.
  • This is a payload only. It does not simulate an actual failed network request, timeout or connection drop.

Practical tips

  • Test the error path your users will actually hit — a timeout and a 500 fail very differently in a client.
  • Check your code distinguishes a 4xx from a 5xx. Retrying a 400 forever is a common and expensive bug.

Each part of the result is chosen independently with your browser's cryptographic random number generator, so every option in a bank is equally likely. How Generate Random works.

Frequently asked questions

Why might the code and status not match realistically?
Because each field — the error code, the message and the HTTP status — is drawn independently from its own fixed list rather than as a matched triple, so you might see NOT_FOUND paired with a 500 status. Treat it as a payload in the right shape for testing your client's parsing, not as a realistic error your actual API would send.