Free tools Writing

Remove duplicate lines and tidy any list

Paste a list and get it back without duplicates or blank lines, trimmed, sorted and numbered the way you want. It all runs on your device, so your text is never uploaded.

Clean up
Order
Add to each line

Applied in this order: trim, remove empty lines, remove duplicates, sort, reverse, number, then prefix and suffix.


0 lines · 0 characters

Everything runs on your device. Your text is never uploaded.


The order things happen in

The options always run in the same seven steps, whichever you tick first. That is why trimmed lines dedupe properly, and why line numbers run 1, 2, 3 down the finished list.

  1. 1

    Trim whitespace

    Spaces and tabs at the start and end of every line are removed, so the steps that follow see the bare text.

  2. 2

    Remove empty lines

    Lines with nothing in them, or nothing but spaces and tabs, are dropped and counted as empty removed.

  3. 3

    Remove duplicates

    The first copy of each line stays where it is and later copies are dropped, compared with or without case and surrounding whitespace.

  4. 4

    Sort

    A to Z, Z to A, by length, naturally so that file2 comes before file10, or shuffled with the browser's secure random number generator. Lines that tie keep their order.

  5. 5

    Reverse

    The whole list is turned upside down, after any sort, so the last line comes first.

  6. 6

    Number

    Each line gets its position in the finished order, written as 1. , 2. and so on.

  7. 7

    Prefix and suffix

    Your prefix goes in front of every line and your suffix after it, outside the line number, so a prefix of - gives - 1. apple.


Questions

Built by Mohd Shayan. Found a problem or have an idea? Send a note.

Which duplicate is kept, and does case matter?

The first copy of a line stays exactly where it is, with its original spelling and spacing, and every later copy is removed. With Case-sensitive on, Apple and apple are different lines: the list apple, Apple, banana, apple keeps apple, Apple and banana, removing one duplicate. Switch it off and the same list keeps only apple and banana, removing two.

In what order are the options applied?

Always the same seven steps: trim, remove empty lines, remove duplicates, sort, reverse, number, then prefix and suffix. The order matters. Trimming first means apple and apple  count as one line. Numbering after sorting means the numbers run 1, 2, 3 down the finished list. The prefix goes on last, so a prefix of -  with numbering gives - 1. apple.

What is the difference between A to Z and natural sort?

A to Z sorts in dictionary order, so apple comes before Banana instead of every capital jumping to the front, but it compares digits one character at a time: img1.png, img10.png, img2.png. Natural sort reads each run of digits as a number and gives img1.png, img2.png, img10.png, which is what you want for file names and version numbers. Random shuffle is a Fisher-Yates shuffle fed by crypto.getRandomValues, so every order is equally likely.

How are spaces and empty lines handled?

Trim whitespace removes spaces and tabs from both ends of every line. Ignore surrounding whitespace when comparing treats apple  as a duplicate of apple while leaving the surviving line exactly as you typed it. Remove empty lines drops blank lines and lines that hold only spaces or tabs, and reports them as empty removed. Without it, blank lines are ordinary lines, so duplicate removal keeps the first blank line and drops the rest.

Is my list uploaded, and how long can it be?

No. Everything happens in your browser with plain JavaScript, and the page makes no network request with your text. Copying and downloading are done by the browser on your device too. Processing a 50,000-line list takes a fraction of a second on an ordinary laptop; drawing that much text into the two boxes is what keeps the browser busiest. The practical limit is how much text your browser can hold in a text box.