JSON Object Randomizer

Randomly reorders a JSON object's top-level key order using an unbiased Fisher-Yates shuffle over its entries. Every value stays attached to its original key; only the order keys appear in changes. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-24

Overview

Introduction

JSON objects are unordered by specification, but real code sometimes accidentally depends on key order anyway. This tool shuffles a JSON object's key order to help surface that kind of hidden dependency, or just to produce a differently-ordered sample document.

Every value stays attached to its original key; only the order the keys appear in the serialized output changes.

What Is JSON Object Randomizer?

A shuffler that parses a JSON object, applies a Fisher-Yates shuffle to its key-value entries, and rebuilds a new object in that shuffled order.

It operates only on the object's own top-level properties; nested objects and arrays inside those values are left completely untouched.

How JSON Object Randomizer Works

The tool reads the object's entries with Object.entries(), which preserves each key's associated value as a pair, then runs a Fisher-Yates shuffle over the array of pairs.

It rebuilds a new object by inserting the shuffled pairs one at a time, so the new object's own insertion order reflects the shuffle, subject to JavaScript's integer-key-first iteration rule.

When To Use JSON Object Randomizer

Use it to test whether code that consumes your JSON (a UI, a diffing tool, a serializer) accidentally depends on key order when it shouldn't.

It's also useful for producing a differently-ordered but semantically identical sample document, for example, to confirm a downstream system treats two key orderings as equivalent.

Features

Advantages

  • Uses Fisher-Yates, which is provably unbiased, rather than a naive sort-based shuffle.
  • Guarantees every value stays correctly paired with its original key.
  • Doesn't touch nested objects or arrays inside the top-level values.

Limitations

  • Only reorders the top-level object's own keys; nested objects keep their own original key order.
  • Integer-like string keys ("0", "1") always sort first regardless of the shuffle, per JavaScript's own object iteration rules, so an object made up mostly of such keys won't visibly reorder.

Examples

Shuffling key order

Input

{"name":"Ada","age":30,"active":true}

Output

{
  "active": true,
  "name": "Ada",
  "age": 30
}

The three keys are reordered; every value stays attached to its original key.

Non-object input

Invalid input

["a", "b"]

Parser error

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

A top-level array has no key order to shuffle, so the tool reports an error instead of guessing.

Corrected version

{"list": ["a", "b"]}

Best Practices & Notes

Best Practices

  • Use this to stress-test code that reads a JSON object's keys via a loop, confirming behavior doesn't depend on the order they appear in.
  • If your object has integer-like string keys and you need to see them visibly move, add a non-numeric prefix first, since JavaScript always orders integer-like keys first regardless of shuffling.
  • Keep the original object around for comparison, since a shuffled key order is visually different but semantically identical JSON.

Developer Notes

The rebuild step inserts shuffled entries into a brand-new object one at a time (`shuffled[key] = value`) rather than using `Object.fromEntries()`, functionally equivalent, but written this way to make the pass-through behavior explicit and easy to follow next to the shuffle step above it.

JSON Object Randomizer Use Cases

  • Testing that downstream code doesn't depend on JSON object key order
  • Producing a reordered but semantically identical sample document
  • Demonstrating JavaScript's integer-key-first iteration quirk with a concrete example

Common Mistakes

  • Assuming JSON objects have a meaningful order to begin with; per the JSON spec they don't, key order is purely a serialization detail.
  • Expecting integer-like string keys ("0", "1") to shuffle like any other key; JavaScript always iterates those first regardless of insertion order.

Tips

  • To shuffle an array's item order instead of an object's key order, use Randomize JSON Array.
  • Pair this with JSON Diff to confirm two differently-ordered objects are still recognized as structurally identical.

References

Frequently Asked Questions