Randomize List and Shuffle Lines
Paste your list with one item per line and it comes back in a random order at once. Press Shuffle again for a new order, then copy or download it.
0 words 0 characters 0 lines
Continue with this text: Pick at randomSort linesNumber the lines
Your text stays in your browser: nothing is uploaded or stored on a server.
How to shuffle a list
- Paste your list into Your list (one item per line), or press Open file to load a .txt or .csv file. Press Example to try it with seven names.
- Read the result. The shuffled list appears in the Result box as soon as there is text. Each edit to the list or the option gives a new order.
- Press Shuffle again for a different order as often as you like. Each shuffle starts again from your original list, so earlier results do not affect the next one.
- Copy or save it with Copy or Download .txt. Use as input moves the result into the input box, and the buttons under the result pass it on to Sort lines, Pick at random or Add line numbers.
The result changes every time you press a key in the input box, so finish editing the list before you copy the order you want to keep.
What counts as an item
The tool shuffles whole lines. A new line starts at every line break, whether the text uses Windows (\r\n), old Mac (\r) or Unix (\n) line endings; the result always uses plain \n line breaks. Within a line nothing changes: spaces, punctuation, numbering, emoji and accented letters stay exactly as you typed them.
| Your input | How it is treated |
|---|---|
Mia listed twice |
Two separate items; both copies are kept and shuffled. |
indented |
One item; the leading spaces stay. |
a, b, c on one line |
One item. Put each item on its own line first, or use the comma separator to convert between commas and lines. |
Q1. Capital of France? |
One item; the number moves with the question. |
| An empty or spaces-only line | Removed when Remove empty lines first is ticked; otherwise shuffled like any other line. |
| A single line | Comes back unchanged, since there is nothing to swap. |
The Remove empty lines first option
The tool has a single option, ticked by default. It removes every line that is empty or contains only spaces or tabs before shuffling. A list copied from a spreadsheet or document often ends with a line break or has blank lines between groups, and without this option those blanks would be scattered through your result.
Untick it when the empty lines are items too, for example blank slots in a schedule. The trailing line break at the end of a list then counts as one empty item.
| Input | Option ticked | Option unticked |
|---|---|---|
Team A, blank, Team B, blank, Team C |
Team C, Team A, Team B |
Team A, Team B, blank, Team C, blank |
red, green, blue and a final line break |
3 lines out | green, red, blank, blue |
These results come from running the tool. Your results will differ because each run is random.
How the shuffle works
The tool uses the Fisher-Yates shuffle (also called the Knuth shuffle). It walks the list from the last line to the first and swaps each line with a randomly chosen line at or before its position. Done this way, every possible order of the list has the same chance, and each line has the same chance of ending up first, last or anywhere between.
The random numbers come from crypto.getRandomValues(), the browser’s Web Crypto API. MDN describes it as giving cryptographically strong random values, unlike Math.random(). In a test of 600,000 shuffles of A, B, C with this code, each of the six possible orders came up between 99,563 and 100,316 times, close to the expected 100,000.
The number of possible orders grows fast: 3 items have 6 orders, 7 items have 5,040, 10 items have 3,628,800 and a deck of 52 cards has a number with 68 digits. Because the original order is one of those possibilities, a short list sometimes comes back unchanged: half the time with two lines, one time in six with three.
Long lists are fine: in a test with Node.js, this code shuffled a 100,000-line list in about a quarter of a second. For very large texts the page waits for a short pause in typing before it shuffles.
Worked examples
Seven names (the Example list), shuffled once:
Before After
Alice Carmen
Ben Farah
Carmen Ben
Dmitri Dmitri
Esi Alice
Farah Esi
Gus Gus
Some names can stay where they were. That is normal in a random order: with seven names, on average one of them stays in its original place.
Quiz questions with a trailing line break, option ticked:
Before After
Q1. Capital of France? Q4. H2O is?
Q2. 7 × 8? Q1. Capital of France?
Q3. Largest ocean? Q2. 7 × 8?
Q4. H2O is? Q3. Largest ocean?
The question numbers stay attached to their questions. To renumber them in the new order, remove the old numbers with Find and replace (tick Regular expression, find Q\d+\. and leave Replace with empty), then use Add line numbers.
When people randomize a list
- Presentation or speaking order. Paste the names of the people or teams and read the result from the top.
- Classroom work. Shuffle quiz questions to make different versions of a test, or shuffle student names to form groups, then split the list into equal parts with the text splitter.
- Giveaways and raffles. Shuffle the entries and take the top lines, or use the random line picker to draw a set number of winners with or without repeats.
- Playlists, reading lists and to-do lists. Break a fixed habit by working through items in a new order.
- Testing and data work. Shuffle rows of a CSV (without the header line) before splitting them into training and test sets, or to check that code does not depend on input order.
Shuffling in Excel, Python or the command line
If the list lives somewhere else, you can shuffle it there:
- Excel for Microsoft 365, 2021 and 2024:
=SORTBY(A2:A20,RANDARRAY(ROWS(A2:A20)))returns the range in random order. Microsoft’s SORTBY help page shows the same pattern. RAND and RANDARRAY recalculate whenever the sheet changes, so paste the result as values to keep it. - Older Excel: add a helper column with
=RAND(), sort the list by that column, then delete it. - Linux and bash:
shuf file.txtprints the lines of a file in random order,shuf -n 3 file.txtprints three random lines, andshuf -o file.txt < file.txtshuffles the file in place. The GNU manual states that each output order is equally likely. - Python:
random.shuffle(items)shuffles a list in place and returnsNone;random.sample(items, k=len(items))returns a new shuffled list and leaves the original alone.
To put a shuffled list back into order, use Sort lines. The guide how to alphabetize a list covers the sorting rules.
Questions
How do I randomize a list of names?
Paste the names with one name per line, and the result box shows them in a random order straight away. Press Shuffle again until you are happy, then press Copy. To draw only one or a few names, use the random line picker instead.
Is the shuffle really random?
Each order is equally likely. The tool uses the Fisher-Yates shuffle with random numbers from your browser's Web Crypto API (crypto.getRandomValues), which MDN describes as cryptographically strong. Nobody, including us, can choose or predict the order.
Why did my list come back in the same order?
A true shuffle can return the original order, because that order is one of the possible results. With 2 lines it happens half the time, with 3 lines one time in 6, and with 7 lines one time in 5,040. Press Shuffle again for another order.
Does it remove duplicate lines?
No. Every line is kept, so a name listed twice appears twice in the result. Run the list through Remove duplicate lines first if each entry should appear once.
How do I randomize a list in Excel?
In Excel for Microsoft 365, 2021 or 2024, enter =SORTBY(A2:A20,RANDARRAY(ROWS(A2:A20))) in an empty cell, changing the range to match your list. The order changes every time the sheet recalculates, so copy the result and paste it as values to keep it. In older versions, put =RAND() in a helper column and sort by that column.
How do I shuffle lines in a file on Linux or in bash?
Use shuf from GNU coreutils, for example shuf names.txt > shuffled.txt. To overwrite the same file, use shuf -o names.txt < names.txt, which is safe because shuf reads all input before writing.
Is my list uploaded anywhere?
No. The shuffle runs in your browser. The text stays in this tab so it is still there if you open another tool, and it is gone when you close the tab.