Format Code Now
/
TextShuffle Lines Next: Add Line Numbers ›

Shuffle Lines

TX-18

Paste a list and get its lines back in random order. A second button shuffles every word in the text instead.

Runs in your browser. Nothing is uploaded.

Lines to shuffle

Shuffled

How to use it

  1. Paste your list into the input box, one item per line.
  2. Choose Shuffle lines to reorder the lines, or Shuffle words to mix every word.
  3. Tick Remove empty lines first if blank lines should not take part.
  4. Press the button again for a new order, then copy the result or download it as a .txt file.

How the shuffle works

Shuffle lines uses the Fisher-Yates method. It walks from the last line to the first and swaps each line with a randomly chosen line at or before it. The random numbers come from the browser crypto generator, and values that would favor some positions over others are thrown away and redrawn, so every ordering is equally likely. The result changes each time you press the button, and the order is not saved anywhere.

Shuffling words instead of lines

Shuffle words splits the whole text at spaces, tabs and line breaks, mixes the words and joins them with single spaces. Because of that, the original line breaks are lost. Punctuation stays attached to the word it touches, so a comma stays with the word before it even when that word moves. Use it for quick word games or test data. For a list where each item matters as a whole, use Shuffle lines.

Questions people ask

How do I shuffle lines of text online?

Paste the lines into the input box and press Shuffle lines. Each line stays whole and only the order changes. Press the button again to get a different order. Copy the result or download it as a text file.

Is the shuffle really random?

It uses the browser crypto random generator and a Fisher-Yates shuffle that avoids modulo bias, so every ordering of the lines is equally likely. It is suitable for drawing names or ordering a list. It is not a way to make a verifiable draw, because nothing is recorded.

Can I get the same shuffle twice?

No. There is no seed and nothing is stored, so each press gives a new order. If you need a result you can reproduce, copy the output right away and keep it.

What happens to blank lines?

Blank lines are shuffled like any other line unless you tick Remove empty lines first. A single empty line at the very end, caused by a trailing line break, is ignored.

Does Shuffle words keep my line breaks?

No. It treats the whole text as one list of words and joins them with single spaces, so the line structure is lost. Use Shuffle lines if you want to keep each line as it is.

About this tool

Each press gives a new order, so the result changes every time you click, and the page re-shuffles when you edit the input. Shuffle lines uses the Fisher-Yates method with numbers from the browser crypto generator, and picks each position without modulo bias. Shuffle words splits the whole text on spaces and line breaks and joins the words with single spaces, so line breaks are lost. Punctuation stays attached to its word. A final empty line from a trailing line break is ignored. Nothing is remembered, so you cannot repeat a shuffle.

Format Code Now: free, no ads, no accounts. Your input stays in your browser.