ToolNimba Browse

🔀 Random Line Shuffler

By ToolNimba Editorial Team · Updated 2026-06-19

Options
0
Lines in
0
Lines out

Paste a list above, then press Shuffle.

This tool puts a list of text lines into a random order. Paste your lines in the box (one item per line), press Shuffle, and the rows are rearranged into an unbiased random sequence. Not happy with the draw? Press Re-shuffle for a fresh order. You can also trim stray spaces, drop blank lines, and remove duplicates before shuffling, then copy the result with one click. Everything runs in your browser using your device's secure random generator, so your text is never uploaded anywhere.

What is the Shuffle Lines?

Shuffling lines means changing the order of the rows at random while leaving the text on each line untouched. Each line break (Enter) marks the boundary between items, so a list of names, tasks, options, or numbers becomes a set of items the tool can reorder. The goal is a result where every possible arrangement is equally likely, the same fairness you expect from a well-shuffled deck of cards.

Under the hood this tool uses the Fisher-Yates shuffle (also called the Knuth shuffle). It walks through the list from the last item to the first, and at each step swaps the current item with one chosen at random from the positions at or before it. Done correctly, this produces a uniform permutation: with n lines there are n factorial possible orders, and each one has an equal chance of appearing. A naive approach, such as sorting by a random key or repeatedly picking from the whole list, can quietly favour some orders over others, so the algorithm matters.

Randomness quality matters too. Math.random is fine for casual use but is not designed to be unpredictable. This tool instead seeds each swap with crypto.getRandomValues, the browser's cryptographically secure random number generator, and uses rejection sampling so there is no modulo bias toward lower numbers. The practical upshot is a shuffle that is both uniform and hard to predict, which is what you want when the order needs to feel genuinely fair.

When to use it

  • Randomizing the order of names to decide who goes first, draws a prize, or picks a seat.
  • Shuffling a list of questions, flashcards, or quiz prompts so you do not memorise the sequence.
  • Putting a playlist, reading list, or set of tasks into a fresh random order each day.
  • Creating a randomized running order for presentations, demos, or interview slots from a plain list.

How to use the Shuffle Lines

  1. Paste or type your list into the input box, one item per line.
  2. Optionally tick Trim spaces, Drop empty lines, or Remove duplicate lines first.
  3. Press Shuffle to randomize the order of the lines.
  4. Press Re-shuffle for a different random order, or Copy to grab the result.

Formula & method

Fisher-Yates shuffle: for i from n-1 down to 1, pick a random index j with 0 <= j <= i, then swap line[i] with line[j]. Each random j comes from crypto.getRandomValues with rejection sampling, giving an unbiased uniform permutation (one of n! equally likely orders).

Worked examples

You have 4 lines: Alice, Bob, Carol, Dave, and you want a fair random order.

  1. Start with the list [Alice, Bob, Carol, Dave], positions 0 to 3.
  2. i = 3: pick random j in 0..3, say j = 1, swap line[3] and line[1] -> [Alice, Dave, Carol, Bob]
  3. i = 2: pick random j in 0..2, say j = 0, swap line[2] and line[0] -> [Carol, Dave, Alice, Bob]
  4. i = 1: pick random j in 0..1, say j = 1, swap line[1] with itself -> [Carol, Dave, Alice, Bob]
  5. i = 0: loop stops (a single remaining item is already placed).

Result: One possible shuffled order: Carol, Dave, Alice, Bob (any of the 24 orders is equally likely).

A 5-line list of quiz questions is shuffled, and you check how many orders are possible.

  1. With 5 lines there are 5! = 5 x 4 x 3 x 2 x 1 = 120 possible orders.
  2. Each Shuffle draws one of those 120 arrangements with equal 1/120 probability.
  3. Pressing Re-shuffle draws again independently, so you may get the same or a different order.
  4. The chance of getting the exact same order twice in a row is 1 in 120.

Result: There are 120 equally likely orders, and Re-shuffle picks one fresh each time.

How the number of lines grows the count of possible shuffled orders (n factorial)

Lines (n)Possible orders (n!)Chance of any one order
361 in 6
4241 in 24
51201 in 120
103,628,8001 in 3.6 million
151,307,674,368,0001 in 1.3 trillion

Common mistakes to avoid

  • Expecting every shuffle to look very different. Random does not mean maximally scrambled. A fair shuffle can leave an item near where it started, or put two items back next to each other. With short lists this is common and is not a sign the tool is broken.
  • Assuming Re-shuffle never repeats. Each shuffle is independent, so the same order can come up twice, especially with only a few lines. The tool does not avoid repeats on purpose, since doing so would make the result less random.
  • Forgetting that blank or duplicate lines count as items. Unless you tick Drop empty lines or Remove duplicate lines, blank rows and repeats are shuffled in like any other line. Clean the list first if you want them gone.
  • Treating a sort as a shuffle. Sorting by a random number can introduce subtle bias and is slower for large lists. A proper Fisher-Yates pass, like this tool uses, is the reliable way to get a uniform random order.

Glossary

Shuffle
Rearranging items into a random order, ideally one where every arrangement is equally likely.
Fisher-Yates shuffle
A simple algorithm that walks a list once, swapping each item with a randomly chosen earlier one, to produce an unbiased random order.
Permutation
One specific ordering of a set of items. A list of n items has n factorial possible permutations.
Factorial (n!)
The product of all whole numbers from 1 up to n, which counts how many orders n items can be arranged in.
crypto.getRandomValues
The browser's cryptographically secure random number generator, used here to make each swap fair and unpredictable.
Modulo bias
A subtle skew toward smaller values that happens when raw random bits are reduced with a plain remainder. Rejection sampling avoids it.

Frequently asked questions

How does the line shuffler work?

It splits your text into lines on each line break, then applies a Fisher-Yates shuffle: it walks the list once and swaps each line with a randomly chosen earlier one. The random choices come from your browser's secure crypto.getRandomValues generator, so every possible order is equally likely.

Is the shuffle truly random and fair?

Yes, as fair as your device allows. The Fisher-Yates algorithm produces a uniform permutation (no order is favoured), and seeding it with crypto.getRandomValues plus rejection sampling removes modulo bias. The result is both unbiased and hard to predict.

What is the difference between Shuffle and Re-shuffle?

They do the same thing: both produce a new random order of your current lines. Shuffle is the main button you press first, and Re-shuffle is a quick way to draw another order if you want a different result. Each press is independent.

Can the same order come up twice?

Yes. Each shuffle is independent, so repeats are possible, and they are likely with short lists. For example, a 5-line list has a 1 in 120 chance of landing in the same order twice in a row. This is expected behaviour for a fair shuffle.

Does my text get uploaded anywhere?

No. The tool runs entirely in your browser using client-side JavaScript. Your list is never sent to a server, so you can safely shuffle private names, answers, or notes without anything leaving your device.

What happens to blank lines and duplicates?

By default blank lines are dropped and duplicates are kept. You can change this with the options: tick Remove duplicate lines to keep only the first of each repeat, untick Drop empty lines to shuffle blanks in, or tick Trim spaces to clean each line first.