Skip to content
AgileLogics

Text Lines Shuffler

Randomly reorders the lines of your text using a Fisher-Yates shuffle with a cryptographically secure random source.

How it works

Paste text (one item per line) into the input panel and click Generate.

How do you shuffle lines of text into random order?

Paste your list, one item per line, and click Generate. The tool drops any line breaks at the very end of the text, splits it at each remaining line break, puts the lines in a random order with a Fisher-Yates shuffle and joins them back together. Every possible ordering is equally likely, and the lines themselves are untouched: duplicates, indentation and blank lines in the middle all survive, only their positions change.

Good uses include deciding the running order for presentations, mixing up quiz questions, randomising the order of test cases or survey options, and breaking up a list that was accidentally left sorted.

Shuffling a list

  1. Paste or type the list into the input box, one item per line.
  2. Click Generate. The shuffled list appears in the output.
  3. Click Generate again for a different order, or Copy to keep this one.

Each click shuffles your original input from scratch, so you can't accidentally shuffle a shuffle into something less random.

A worked example with a trailing newline

Lists copied from editors and spreadsheets usually end with a line break. The input was these four lines followed by a final newline:

one
two
three
four

One shuffle produced:

one
four
two
three

The final line break is removed before shuffling, so it doesn't turn into a fifth, empty "line" that could land anywhere in the result. You get exactly the four items back, in a new order.

Exactly what's preserved

In your input In the output
Repeated lines Kept, each copy shuffled independently
Leading or trailing spaces on a line Kept
Blank lines in the middle Kept, and moved like any other line
Line breaks at the very end Removed, so no empty line appears in the result
Windows CRLF line endings Recognised; output uses LF
Only whitespace No output

If you want duplicates gone first, run the list through the duplicate line remover. If you only need a few winners rather than the whole list reordered, the random name picker draws up to 20 names and ignores blanks and repeated names.

Why Fisher-Yates, and why it matters

The Fisher-Yates shuffle (in the form Richard Durstenfeld popularised for computers) walks from the last line to the first. At each position it picks a random line from the ones not yet placed, including the current one, and swaps them. For n lines that's n − 1 swaps, and every one of the n! orderings comes out with the same probability.

The common shortcut in JavaScript, list.sort(() => Math.random() - 0.5), looks similar and isn't. A sort expects a consistent comparison, and feeding it random answers produces orders whose odds depend on the browser's sorting algorithm, with some arrangements turning up more often than others. This tool avoids both problems: it uses a real Fisher-Yates loop, and each swap position comes from crypto.getRandomValues() rather than Math.random(), mapped by rejection sampling so no position is favoured.

How many orders are there? The count grows fast:

Lines Possible orders
5 120
10 3,628,800
20 about 2.4 × 10^18
52 (a deck of cards) about 8.1 × 10^67

Related tools

The text sorter puts lines back into A-Z or numeric order, and also has its own random mode. That mode also trims a trailing line break before shuffling but uses Math.random(), so prefer this page when the order needs to be unpredictable, such as assigning people to groups. To check how many lines and words you're working with, paste the list into the word counter.

Last updated

Frequently asked questions

Is every order equally likely?
Yes. The tool uses a Fisher-Yates shuffle driven by crypto.getRandomValues, which gives each of the possible orderings the same probability. A list of 10 lines has 3,628,800 possible orders.
Why is there a blank line in the middle of my result?
Your input had a blank line somewhere in the list, and blank lines in the middle are kept and shuffled like any other line. Line breaks at the very end of the input are different; they're removed before shuffling, so a list pasted with a final newline doesn't gain an empty line.
Does it remove duplicates or trim spaces?
No. Every line is kept exactly as typed, including repeated lines and leading or trailing spaces. Only the order changes.
What happens to Windows line endings?
CRLF and LF line breaks are both recognised, and the output always uses LF. Most editors handle that without you noticing.
Is my text uploaded?
No. The shuffle runs in JavaScript in your browser and nothing is sent to a server.