Random JSON Generator

Press Generate for one pretty-printed sample JSON object with nested preferences and history, ready to copy into a test or mock.

Press Generate and the Random JSON Generator shows one sample JSON object, indented with two spaces, with a copy button in the corner. The object is picked at random from 50 fixtures we wrote for the page, all sharing the same shape: a user-style record with a nested preferences object and an array of history events. It's a quick way to grab a realistic-looking nested object for a unit test, a README example or an API mock without writing one by hand.

The shape of every object

All 50 fixtures use these fields, so whatever you get will parse against the same schema:

{
  "id": 2370,
  "name": "UexAMPvd",
  "is_active": false,
  "date_joined": "2014-06-01",
  "score": 82.33,
  "preferences": {
    "color": "yellow",
    "likes": ["E6DRw9"]
  },
  "history": [
    { "date": "2014-12-12", "action": "login" },
    { "date": "2014-07-20", "action": "delete" }
  ]
}
  • id: a four-digit integer.
  • name: a random alphanumeric string, deliberately not a real name.
  • is_active: a boolean.
  • date_joined: an ISO 8601 date string.
  • score: a float with two decimals.
  • preferences.color: one of red, green, blue, yellow or purple; preferences.likes: an array of short random strings.
  • history: one or more events, each with a date and an action of login, logout, update or delete.

That mix covers the JSON types most parsers need exercising: integer, float, boolean, string, nested object, array of strings and array of objects. There's no null and no deeply recursive nesting.

What you can't set

This tool has no schema editor, field picker or record count. It returns one object per press from a fixed pool, so it isn't a substitute for a faker library when you need a thousand rows or a custom structure. If you need random values of one particular type, the site has single-purpose tools: the Random Email Generator, Random IP Generator, Random MAC Address Generator and Random String Generator each produce one field's worth of data you can paste into a template.

Ways people use it

  • Fixture for a parser test. Copy the object into a test file to check that your deserializer handles nested objects and arrays of objects together.
  • Placeholder in API docs. A response example that looks like real data but obviously isn't (the random name strings make that clear).
  • Teaching JSON syntax. The sample has every bracket type and value type in a dozen lines, which makes it a decent whiteboard example.
  • Seeding a mock endpoint. Press a few times, paste the objects into an array, and serve it from a local mock server while the real API is being built.

Related developer tools

For keys and tokens to go alongside the mock data, see the Random API Key Generator and Encryption Key Generator, or browse all developer & test data tools.

Frequently asked questions

Can I define my own JSON schema or fields?

No. Every result uses the fixed structure shown above. For a custom schema you'll need a faker library or a schema-based mock tool.

Is the output valid JSON?

Yes. The object is serialized with JSON.stringify and pretty-printed with two-space indentation, so it pastes cleanly into any JSON file or parser.

How many different objects are there?

50. Each press picks one at random, so you may see the same object again on later presses.

Can I generate an array of many records?

Not in one press. Press several times and copy each result into an array yourself.