Home / Text tools / Shuffle lines

Shuffle Lines

Randomize the order of the lines in any text. Keep the first line in place, or shuffle each paragraph block on its own.

Result

Shuffle the lines of a text

Paste text with one item per line, such as a list of names, a set of questions or the rows of a data file, and the lines come back in random order. Lines are separated by line breaks, so this works on any text and on files from any system.

Keep the first line in place

Files such as CSV exports start with a header row. Tick Keep the first line in place and the header stays at the top while all the other lines are shuffled below it.

Name,Score          Name,Score
Anna,91             Dev,66
Ben,78      ->      Anna,91
Cara,85             Eli,92
Dev,66              Cara,85

Shuffle each block separately

If your text has groups of lines separated by a blank line, such as sets of questions with their answers, tick Shuffle each block separately. The lines are shuffled inside each block, the blocks stay in their original order, and the blank lines between them are kept.

Options

  • Trim spaces: removes spaces at the start and end of each line.
  • Remove empty lines: drops blank lines before shuffling.
  • Remove duplicate lines: keeps the first copy of a repeated line.

Good to know

The shuffle is fair: every order is equally likely, using the Fisher-Yates algorithm with the browser secure random number generator. Nothing is uploaded, because the work is done in your browser.

To put lines in order instead, use sort lines. To count them, use the line counter. For lists split by commas or spaces, use shuffle list.

Frequently asked questions

How do I shuffle lines of text?

Paste the text into the box. The lines are put in random order at once. Press Shuffle for a new order.

Can I keep the header row of a CSV file?

Yes. Tick Keep the first line in place and the header stays where it is.

What does Shuffle each block separately do?

It treats groups of lines separated by blank lines as blocks and shuffles the lines inside each block without moving the blocks.

Does it change my lines?

Only if you choose an option such as trim or remove duplicates. Otherwise each line is kept exactly as it is.