đ Shuffle Lines
Randomize and shuffle the order of text lines instantly. Perfect for creating random lists, randomizing surveys, shuffling data entries, and mixing up line sequences. Uses Fisher-Yates algorithm for uniform distribution.
- Paste your text with one item per line
- Click "Shuffle Lines" to randomize the order
- Uses Fisher-Yates shuffling algorithm for fair randomization
- Blank lines are preserved in their randomized positions
- Each shuffle produces a different random order
- Statistics show total, blank, and content lines
đ Examples:
Blank Lines: 0
Content Lines: 5
- Randomize survey response options
- Shuffle playlist or song lists
- Mix up test questions or exam items
- Randomize game participant lists
- Create random drawing order for contests
- Shuffle TODO lists or task priorities
- Generate random data order for analysis
Why the shuffle runs backwards
Fisher-Yates starts at the last line and works up, swapping each line with one drawn from the part of the list that has not been placed yet:
for i = n-1 down to 1:
j = floor(Math.random() * (i + 1)) // 0 .. i inclusive
swap lines[i] and lines[j]
Because the draw range shrinks by one each step, every one of the n! possible
orderings is equally likely. The tempting one-liner -
sort(() => Math.random() - 0.5) - is not equivalent: it feeds an
inconsistent comparator to a sort routine and leaves items near where they
started.
How random the randomness is
- The source is
Math.random, a fast pseudo-random generator, notcrypto.getRandomValues. There is no seed you can set, so a shuffle cannot be reproduced or audited afterwards. - Long lists cannot reach every ordering. The generator holds about 2128 internal states, roughly 3 x 1038, while 35 lines already have 1 x 1040 arrangements. The result is still unpredictable in practice; it is simply not exhaustive.
- Blank lines are shuffled like any other line and can land at the top. A trailing newline in your input counts as one of them, which is why Total Lines is sometimes one more than you expect.
- Each click reshuffles the original text, so pressing the button five times gives five independent orderings rather than a shuffle of a shuffle.
Frequently asked questions
Could the same order come up twice?
Easily, on a short list. Five lines have only 120 possible orders, so repeats are common. Twenty lines have 2.4 quintillion orderings, so a repeat there will never happen.
How do I shuffle rows in Excel instead?
Put =RAND() in a helper column, fill it down, then sort by that
column and delete it. Pasting a column here is quicker and does not leave
volatile formulas recalculating in the sheet.
Does shuffling change my text in any way?
No. Lines are reordered, never edited - spacing, capitalisation and duplicates all survive intact, and the line count is identical before and after.