JSON Array Randomizer

Randomly reorders the top-level items of a JSON array using an unbiased Fisher-Yates shuffle, leaving each item's own nested contents untouched. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-24

Overview

Introduction

Sometimes you need a JSON array's items in a genuinely random order, for shuffling a quiz question bank, randomizing a playlist, or de-biasing a sample data set before splitting it into train/test sets.

This tool applies a proper Fisher-Yates shuffle to the top-level items and returns the reordered array as JSON.

What Is JSON Array Randomizer?

A shuffler that parses a JSON array and randomly reorders its top-level items in place, using the Fisher-Yates algorithm for a statistically unbiased result.

Only the order of items changes; every item's own value, including any nested arrays or objects inside it, is copied through unchanged.

How JSON Array Randomizer Works

After parsing the input as JSON and confirming the top-level value is an array, the tool copies it and runs a standard Fisher-Yates shuffle: starting from the last index and working backward, each position is swapped with a uniformly random position at or before it.

The shuffled copy is then serialized back to JSON with two-space indentation. The original array (and any objects it contains) is never mutated by this pass, since the algorithm operates on a copy.

When To Use JSON Array Randomizer

Use it when you need to randomize the presentation order of a list, quiz questions, a playlist, a raffle entry list, without changing what's in it.

It's also useful for shuffling a small sample data array before splitting it into subsets, so the split isn't biased by whatever order the data originally arrived in.

Features

Advantages

  • Uses Fisher-Yates, which is provably unbiased, rather than a naive sort-based shuffle.
  • Leaves nested structures inside each item completely untouched.
  • Works on arrays of any value type: objects, strings, numbers, or a mix.

Limitations

  • Only reorders top-level items; it won't shuffle items nested inside sub-arrays.
  • Uses Math.random(), which is not cryptographically secure; don't use this for anything requiring cryptographic randomness (e.g. security tokens or fair lottery drawings with real stakes).

Examples

Shuffling a small array

Input

["a", "b", "c", "d"]

Output

[
  "c",
  "a",
  "d",
  "b"
]

The four items are reordered; the exact result varies on every run.

Non-array input

Invalid input

{"a": 1}

Parser error

Top-level JSON value must be an array to randomize.

A top-level object has no defined item order, so the tool reports an error instead of guessing.

Corrected version

[{"a": 1}]

Best Practices & Notes

Best Practices

  • Use this before splitting a JSON sample data array into train/test subsets, to avoid order-related bias.
  • For cryptographically secure shuffling (e.g. real randomized drawings), don't rely on this tool; use a cryptographic RNG instead.
  • If you need a reproducible shuffle for testing, seed and shuffle in your own code instead, since this tool doesn't expose a seed.

Developer Notes

The shuffle operates on `array.slice()` rather than the parsed array directly, so the function is pure and side-effect free even though Fisher-Yates is normally described as an in-place algorithm; this avoids any risk of mutating shared state if the same parsed value were reused elsewhere.

JSON Array Randomizer Use Cases

  • Randomizing quiz or flashcard question order
  • Shuffling a playlist or content queue
  • De-biasing sample data order before a train/test split

Common Mistakes

  • Expecting nested arrays inside items to also be shuffled; only the top level is reordered.
  • Passing a JSON object instead of an array; wrap it in an array first if you need to shuffle a single-item collection.

Tips

  • Need a brand-new random array instead of reordering an existing one? Use Random JSON Array Generator.
  • To shuffle an object's key order instead of an array's item order, use Randomize JSON Object.

References

Frequently Asked Questions