Skip to contentSkip to the inputSkip to the result

Shuffle text lines

Randomize the order of a list.

Loading tool

Instructions

Shuffle text lines

How to use

  1. Put one item per line and shuffle.
  2. Run again for a new ordering, or deal the list into a number of groups or groups of a set size.

Supported input

  • Uses Web Crypto randomness; repeated text remains repeated.

Input example

A / B / C

Result example

A random permutation, such as C / A / B

Troubleshooting

  • Check required inputs, numeric ranges and the selected conversion direction.

How it works

  • Randomize the order of a list.

Shuffling a list fairly, and repeating a shuffle on purpose

What people shuffle

  • The running order for talks, interviews or a recital, so nobody can say it was arranged.
  • Quiz questions in a different order for each class, with a repeat key per class so the answer sheet can be rebuilt.
  • Answer options in a survey, to dilute the order effect that favours whatever is listed first.
  • A class list dealt into random groups.

Every order equally likely

The shuffle is Fisher–Yates: walk from the last position to the first, and at each one swap in an item chosen uniformly from that position or any before it. Every one of the n! possible orders is then equally likely: 3,628,800 for ten lines, about 8.07 × 10^67 for a deck of 52 cards.

The positions are drawn with the browser’s Web Crypto generator, crypto.getRandomValues. Taking a 32-bit random number modulo the range would favour some results slightly, so values above the largest multiple of the range are thrown away and drawn again. For a choice among ten, the top 6 of the 4,294,967,296 possible values are rejected, leaving exactly 429,496,729 values for each of 0 to 9.

Why the popular one-liner is biased

A common shortcut sorts the list with a comparison that returns a random answer, sort(() => Math.random() − 0.5). Sorting algorithms assume comparisons are consistent, so the result is skewed. Shuffling A, B, C that way 600,000 times in Node.js gave the original order ABC 224,586 times, about 37%, and CAB only 37,409 times, about 6%. A fair shuffle gives each of the six orders about 100,000, or 16.7%. Other JavaScript engines skew differently, but they all skew.

How a repeatable shuffle works

Type anything into the repeat field and it is hashed to a 32-bit starting value (FNV-1a), which drives a small pseudo-random generator (mulberry32) that picks the Fisher–Yates positions. The same list with the same key gives the same order on any device, any day.

Because the starting value has 32 bits, a keyed shuffle can produce at most 2^32, about 4.3 billion, different orders. Thirteen lines already have 6,227,020,800 possible orders, so with a key some of them can never appear. Use a key when you need to rebuild an order, and leave it empty for a draw.

Good to know about groups

Groups are dealt from the shuffled list one name at a time, like cards. Seven people numbered 1 to 7, shuffled with the key “x”, come out as 2, 3, 7, 6, 5, 1, 4; in three groups that gives group 1: 2, 6, 4, group 2: 3, 5 and group 3: 7, 1. Dealing keeps group sizes within one of each other.

  • Asking for more groups than there are names gives one group per name: three names in five groups is three groups of one.
  • A name on two lines counts as two people. Run the duplicate-line tool first if the list may contain repeats.
  • If each group needs a leader, agree beforehand that, say, the first name in each group takes the role, so the draw settles it.

Checked

Frequently asked questions

Can I split a list into random groups?

Yes. Set the number of groups to 2–50; the list is shuffled and dealt out one at a time. Blank lines are left out, and when it does not divide evenly the first groups get one extra. Five names in two groups gives 3 and 2. Switch Split by to People per group to set the group size instead: 10 names at 4 per group gives three groups of 4, 3 and 3.

Can I get the same shuffle again?

Yes. Enter any text in the repeat field and the same list always comes out in the same order. That order can be predicted, so leave it empty for a fair draw, which uses Web Crypto randomness.

Can the shuffled list come out in the original order?

Yes. Three items have 6 possible orders, so the original order comes up 1 time in 6. Without groups, repeated and blank lines stay as items.