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
- Paste or type the list into the input box, one item per line.
- Click Generate. The shuffled list appears in the output.
- 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