Random JSON Generator

Builds a random JSON document from a configurable-depth tree of objects, arrays, strings, numbers, and booleans, so you can quickly get sample data shaped like a real API response for fixtures, mocking, or UI prototyping. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-26

Overview

Introduction

Sometimes you just need some JSON that looks like real data — a nested object with a plausible mix of strings, numbers, booleans, and arrays — without hand-writing a fixture from scratch.

This tool generates exactly that: a random object tree serialized as JSON, with knobs for how deep and how wide it should be.

What Is Random JSON Generator?

A random data generator that produces a JSON document instead of asking for one as input.

Internally it builds a plain object/array tree first, then hands it to JSON.stringify, so correctness of the JSON syntax is guaranteed by the platform rather than by string concatenation.

How Random JSON Generator Works

Starting from an empty root object, the generator recursively decides for each field whether to put a scalar (string, number, or boolean), a nested object, or an array of further random values, stopping once the configured max depth is reached.

The number of keys per object and items per array are both configurable, so you can shape the tree from a flat handful of fields to a wide, deeply nested structure.

The final tree is serialized with JSON.stringify, using your chosen indent width, or no indentation at all for a minified single-line document.

When To Use Random JSON Generator

Use it when you need placeholder JSON to seed a mock API response, a test fixture, or a UI component that renders arbitrary nested data.

It's also handy for quickly checking how a JSON viewer, formatter, or parser handles nested objects and arrays of varying shape.

Features

Advantages

  • Guaranteed syntactically valid JSON, since it's produced by JSON.stringify rather than hand-built strings.
  • Depth, breadth, and indentation are all independently configurable.
  • Runs entirely client-side with no network request, so it works offline and never sends anything anywhere.

Limitations

  • Generated strings and keys come from a small fixed word list, not a realistic name/address/email generator — it's for structural testing, not demo content that needs to look human-authored.
  • There is no way to pin the exact shape of the output (e.g. force a specific key to always be a string); it's a random tree, not a schema-driven generator.

Examples

Shallow object (max depth 1)

Input

(no input; generated from settings)

Output

{
  "id_0": "nova",
  "name_1": 482
}

With max depth 1, fields resolve straight to scalars.

Minified output (indent 0)

Input

(no input; generated from settings)

Output

{"id_0":"nova","name_1":482}

Best Practices & Notes

Best Practices

  • Keep max depth at 2-3 for most fixture needs; higher depths quickly produce very large documents.
  • Use indent 2 for human-readable fixtures you'll commit to a repo, and indent 0 for pasting into a request body.

Developer Notes

The tree builder rolls a fresh random choice (scalar vs. object vs. array) at every field rather than filling every branch to the configured max depth, which is why two runs with identical options can differ noticeably in overall size.

Random JSON Generator Use Cases

  • Seeding a mock REST API response for frontend development
  • Generating a JSON fixture file for a unit test
  • Stress-testing a JSON viewer or formatter with varied nested shapes

Common Mistakes

  • Setting max depth and array length both high, which can produce an unexpectedly huge document (they compound multiplicatively).
  • Assuming the generated field names are meaningful — they're drawn from a small placeholder word list, not domain-specific vocabulary.

Tips

  • Regenerate a few times at the same settings to see a range of shapes before picking one to keep.
  • Pair with a JSON formatter tool if you need to reformat or minify the output further.

References

Frequently Asked Questions