Text & DocumentsLive🔒 Private

Text Line Randomizer

Randomize the order of lines in any text. Free online line shuffler. No signup, 100% private, all processing in your browser.

Text Line Randomizer

How it works

Randomly shuffling a list of lines is needed for: creating randomised question orders in quizzes, shuffling a playlist or reading list, generating random permutations for statistical sampling, and eliminating order bias in surveys (where respondents tend to choose the first option more frequently). The Text Line Randomizer shuffles any line-delimited list using a cryptographically secure random permutation.

**Fisher-Yates shuffle algorithm** The Fisher-Yates (Knuth) shuffle produces an unbiased random permutation in O(n) time. For n items: pick a random index j from [0, i] (inclusive), swap items[i] with items[j], decrement i. This guarantees each of n! permutations is equally likely — unlike naïve sort-by-random-key which has subtle biases depending on the sort algorithm.

**Cryptographic randomness** The shuffle uses `crypto.getRandomValues()` for each random index selection, ensuring no predictable pattern in the output sequence. This matters for security applications (randomising password reset options, shuffling exam question order).

**Order bias in surveys** Research consistently shows that respondents select the first option in a list significantly more often than later options ("position bias" or "acquiescence bias"). Randomising option order across respondents eliminates this confound in survey design. The randomizer can generate multiple unique shuffled versions of the same option list.

**Practical applications** - Teachers: randomise exam question order to prevent copying - Developers: randomise test execution order to detect inter-test dependencies - Researchers: randomise treatment assignment in experiments - Music: shuffle playlists without repetition - D&D dungeon masters: randomise encounter tables or room descriptions

Privacy: all shuffling runs in the browser. Your list content is never transmitted.

Frequently Asked Questions

Why is sorting by Math.random() a bad way to shuffle?
`array.sort(() => Math.random() - 0.5)` is a common but flawed approach. The sort algorithm (typically TimSort) makes repeated comparisons with a 'less than' function that's supposed to be consistent and transitive. A random comparison function violates transitivity (if A>B and B>C, a consistent comparator would say A>C — a random one might not). The resulting permutation distribution is biased in ways that depend on the sort algorithm's internals. Different browsers produce different biases. Fisher-Yates shuffle is the correct O(n) unbiased algorithm.
Is the Fisher-Yates shuffle truly unbiased?
Yes — the Fisher-Yates (Knuth) algorithm produces each of the n! permutations with exactly equal probability 1/n!, provided the random number generator is perfectly uniform. The algorithm: for i from n-1 down to 1, swap element i with element j where j is uniformly random from 0 to i (inclusive). At each step, the selected element is placed in its final position. The proof: element n can be any of the n elements with equal probability 1/n; then element n-1 can be any of the remaining n-1 with equal probability; etc. Total: 1/n × 1/(n-1) × ... × 1/1 = 1/n! for each permutation.
How can I use line randomisation for statistical sampling?
For random sampling from a large list (population): shuffle all lines with Fisher-Yates, then take the first N lines as your sample. This produces a simple random sample without replacement — every item has equal probability of selection, and no item is selected twice. For stratified sampling: shuffle within each stratum separately, then take proportional samples from each. For systematic sampling (every Kth item): sort first, then use an arithmetic sequence starting at a random offset in [0, K-1].
What is order bias in surveys and how does randomisation fix it?
Position bias (also called primacy and recency effects) means survey respondents are more likely to select options that appear first in a list (primacy effect) or sometimes last (recency effect). A 2020 meta-analysis found primacy bias of ~5–10% for option selection in multiple-choice questions. Randomising option order for each respondent eliminates between-respondent order bias — any systematic preference for position averages out. Within-respondent bias remains (the first option they read still has slight advantage for a given individual), but the aggregate data becomes unbiased across respondents.