Shuffle Lines
Randomly reorder the lines of your text.
Lines: 0Characters: 0
Fair, unbiased shuffling
This tool uses the Fisher–Yates algorithm, which gives every possible ordering an equal chance — unlike the common sort(() => Math.random() - 0.5) trick, which is subtly biased. Great for randomizing draw entries, playlists, quiz questions, or test data. Click Shuffle as many times as you like; each pass is independent. Randomization happens entirely in your browser and nothing is stored.
Built and maintained by Meet Shah · Last updated
What this tool is used for
- Randomising a list before selecting from it.
- Shuffling questions or prompts for a quiz.
- Randomising a playlist or a rota so the same name is not always first.
- Producing input to test that a sort actually sorts.
- Removing any ordering bias from a list before sampling.
Frequently Asked Questions
- Which shuffling algorithm is used?
- Fisher-Yates, which is the only common algorithm that produces every permutation with equal probability. The naive alternative — sorting with a random comparator — is measurably biased and, worse, is undefined behaviour in some engines.
- Why is sort(() => Math.random() - 0.5) wrong?
- Because sort algorithms assume a consistent comparator. A random one violates that, so results are biased toward certain permutations and vary by engine. It is one of the most widely copied incorrect snippets in JavaScript.
- Is the shuffle cryptographically secure?
- Only if it draws from crypto.getRandomValues. Math.random is a fast statistical PRNG whose state can be recovered from a modest number of outputs, so it must not be used for prize draws or anything with an incentive to predict.
- Can I reproduce the same shuffle later?
- Not from a cryptographic source, by design — it takes no seed. Reproducible shuffling requires a seeded PRNG, which is a different and deliberately weaker tool suited to test fixtures rather than draws.
- Are duplicate and blank lines preserved?
- Yes — shuffling reorders, it does not deduplicate or clean. A trailing newline may produce a blank entry that shuffles like any other line, which surprises people expecting it to be ignored.
- How many permutations exist for a modest list?
- More than a generator can reach. 52 items have 52! arrangements, vastly exceeding the state space of a typical PRNG — so most possible orderings are literally unreachable, which matters for anything claiming fairness.
- Does shuffling twice make it more random?
- No. A single Fisher-Yates pass already produces a uniformly random permutation; shuffling again yields another uniform permutation and no additional randomness. It is the algorithm, not the repetition, that matters.
- How do I shuffle a very large file?
- Not by loading it all — reservoir sampling picks a random subset in one pass with constant memory, and a full shuffle of a file too large for memory needs an external sort on random keys.
Common errors and gotchas
- Shuffling a file whose first line was a header, which then lands in the middle.
- Assuming a shuffle is a sample, when it reorders everything rather than selecting.
- Reshuffling until the order looks random, which makes it less random.
- Shuffling lines whose order carried meaning, such as a sequence of steps.
- Overlooking blank lines, which get shuffled in as if they were entries.
Related tools
Spin the Wheel
Spin a wheel to pick a name at random: paste a list, spin, remove each winner if you like. Every entry has the same chance; nothing leaves your browser.
Yes or No Wheel
Spin an animated Yes or No wheel for a random, unbiased decision. Type an optional question, spin, and keep a tally of your results.
Remove Duplicate Lines
Delete repeated lines and keep your list unique.
Text Diff / Compare
Side-by-side or unified line/character diff comparison tool.
Lines to Comma-Separated List
Join lines into a single comma-separated list.
Comma-Separated to Lines
Split a comma-separated list into one item per line.
Duplicate Line Counter
Count how many times each line appears — sorted by frequency.
Duplicate Line Remover
Remove duplicate lines from text, keeping only unique entries.