Shuffle Lines

Randomly shuffle the lines of any text instantly. Perfect for randomizing lists, quiz questions, or dataset rows.

runs locally on your browser. Your data never leaves your device.

Common Use Cases

Randomise the order of quiz questions or flashcard prompts before a study session
Shuffle a list of names to assign random presentation slots or interview order
Reorder rows in a dataset before splitting into training and validation sets for a machine learning experiment
Break alphabetical order in a slide deck or agenda to prevent audiences from predicting the sequence

About Shuffle Lines

Randomly shuffling a list is one of those operations that sounds trivial but comes up constantly in real workflows. Educators randomise quiz questions and answer choices to prevent cheating and pattern recognition. Developers randomly order test cases or fixtures to catch order-dependent bugs that would otherwise go unnoticed. Data scientists shuffle rows in a CSV before splitting into training and validation sets, ensuring neither set is biased toward a particular ordering in the source data. Technical interviewers shuffle candidate lists to ensure fair random assignment to interviewers.

The underlying algorithm used here is the Fisher-Yates shuffle (also known as the Knuth shuffle), published by Ronald Fisher and Frank Yates in 1938 and adapted for computers by Donald Knuth. The algorithm produces a uniformly random permutation, meaning every possible ordering of N items is equally likely. It runs in O(n) time and O(1) extra space by performing in-place swaps from the last element down to the first, each time picking a random position from the remaining unshuffled prefix. Naïve approaches like sorting by Math.random() or repeatedly picking a random unused element both produce biased distributions and are slower.

The "ignore empty lines" option is useful when pasting lists that have blank separator lines between items, since stripping them ensures blank rows don't count as list entries or end up awkwardly redistributed in the output. The "trim whitespace" option handles lists pasted from spreadsheets or editors where trailing spaces or leading indentation crept in.

This tool is also handy for generating random orderings for tabletop games, selecting a random starting player from a list of names, or simply breaking alphabetical ordering in a presentation slide to avoid audiences anticipating the next item.

Frequently Asked Questions

What algorithm is used to shuffle the lines?
The Fisher-Yates shuffle (Knuth shuffle). Starting from the last line and working down to the first, it picks a random position from the remaining unshuffled lines and swaps. This guarantees every possible ordering is equally probable, unlike sorting by Math.random(), which produces a biased and slower result.
Does clicking Shuffle again produce a different order each time?
Yes. Each click runs the Fisher-Yates algorithm with a fresh Math.random() seed drawn from the browser's PRNG. For small lists (under 10 items) you may occasionally see a similar arrangement by chance (expected, given how few permutations are possible), but for larger lists the output will be meaningfully different on every click.
What does 'Ignore empty lines' do?
When enabled (the default), blank lines in your input are removed before shuffling, so they don't end up scattered randomly through the output. This is useful when your list uses blank lines as visual separators between sections. When disabled, blank lines are treated as valid entries and participate in the shuffle.
What does 'Trim whitespace' do?
When enabled (the default), leading and trailing whitespace is stripped from each line before shuffling. This cleans up lines pasted from spreadsheets, code editors, or documents where invisible spaces may be attached to entries. The trimmed text is what appears in the output.
Is there a line limit?
No hard limit is enforced. The tool handles thousands of lines without issue, since Fisher-Yates runs in linear time. Very large inputs (tens of thousands of lines) will still process in milliseconds in a modern browser.