G
Great Online Apps
Remove Duplicate Lines and Sort Text Online

Remove Duplicate Lines and Sort Text Online

Remove duplicate lines, trim whitespace, delete empty lines and sort lines A to Z in natural order. Free online tool with real before-and-after examples.

To remove duplicate lines from a list, paste it into a duplicate line remover: it keeps the first copy of each line, drops every repeat, and leaves the rest of the list in its original order. That turns a messy list of emails, keywords or URLs into a clean list of unique entries in one step.

Our free Remove Duplicates & Sort Lines tool does this as soon as you paste. It can also trim stray spaces, delete empty lines, ignore differences in capitalization and sort the result A to Z or Z to A. This guide explains what each option does, with a real before-and-after example.

What counts as a duplicate line?

Two lines are duplicates when they match exactly after the options you choose are applied. The tool compares whole lines, not words inside them, so "Apple" and "Apple Inc." are different lines.

Option Default What it does
Remove duplicate lines On Keeps the first occurrence of each line and drops later copies
Trim whitespace On Removes spaces and tabs at the start and end of every line, so " apple " matches "apple"
Ignore case On Treats "Apple" and "apple" as the same line when removing duplicates and sorting
Remove empty lines Off Deletes blank lines from the output
Sort order No sorting Keeps the original order, or sorts A to Z or Z to A

The steps run in a fixed order: trim whitespace, remove empty lines, remove duplicates, then sort. When duplicates are removed with Ignore case on, the version that appears first in your list is the one that stays, with its original capitalization.

Worked example

Paste this list, which has repeats, stray spaces, mixed capitals and blank lines:

banana
Apple
  apple
cherry

banana
item10
item2

Cherry

With the default options, the Cleaned output is:

banana
Apple
cherry

item10
item2

The second "banana", the padded " apple " and "Cherry" are gone because they repeat earlier lines once spaces and capitals are ignored. The two blank lines collapse into one, because a blank line is a duplicate of another blank line. Now turn on Remove empty lines and set Sort order to A to Z:

Apple
banana
cherry
item2
item10

Natural sort vs alphabetical sort

Notice that item2 comes before item10 above. The tool uses natural sort order, which reads runs of digits as whole numbers. A plain character-by-character sort compares "1" with "2" and puts item10 first, which is rarely what you want for file names, version numbers or numbered items.

Input Plain alphabetical sort Natural sort (this tool)
file2, file10, file1 file1, file10, file2 file1, file2, file10

Ignore case matters for sorting too. With it on, "Apple, banana, Cherry" sorts the way a dictionary would. With it off, every line starting with a capital letter comes before every line starting with a lowercase letter, so you get "Apple, Cherry, banana".

How to use Remove Duplicates & Sort Lines

  1. Open the Remove Duplicates & Sort Lines tool.
  2. In Cleanup options, switch Remove duplicate lines, Trim whitespace, Ignore case and Remove empty lines on or off, and choose a Sort order: No sorting, A to Z or Z to A.
  3. Paste your list into Input lines, one item per line. It holds up to 100,000 characters.
  4. Read the result in Cleaned output. It updates whenever you change the text or an option.
  5. Click Copy to copy the cleaned list, or Clear to start over.

Common uses

  • Email lists: merge several exports and remove repeated addresses before a send. Keep Ignore case on, since most email providers treat addresses as case-insensitive.
  • Keyword research: combine keyword lists from several sources, drop duplicates and sort A to Z.
  • URLs and slugs: check a list of planned page addresses for repeats before publishing. Our guide to writing SEO-friendly URL slugs explains why each slug must be unique, and the slug generator creates them.
  • Tags and categories: clean up tag lists where the same tag was typed with different capitals.
  • Spreadsheet columns: paste a single column, remove duplicates, and paste the unique values back.

Tips and common mistakes

  • Turn Ignore case off when capitals carry meaning. Case-sensitive IDs, codes and file paths on Linux servers can differ only by case.
  • Keep No sorting for ranked lists. Sorting discards the original order, so leave it off for priorities, steps or rankings.
  • Leave Trim whitespace on for copied data. Spreadsheets and web pages often add invisible trailing spaces that stop lines from matching.
  • Normalize capitals for a consistent result. The tool keeps the first spelling it meets. To make every line lowercase or Title Case, run the output through the case converter; see our guide to text case styles for which to choose.
  • Check what was removed. Paste the original list and the cleaned list into the text diff viewer to see every line the cleanup dropped.
  • Watch for near-duplicates. Lines that differ by punctuation, such as "Acme Inc" and "Acme Inc.", are not exact matches and both stay.

Frequently asked questions

How do I remove duplicate lines from a list?

Paste the list into a duplicate line remover with one item per line. It keeps the first copy of each line and removes the repeats, leaving the remaining lines in their original order.

Does removing duplicates keep the first or last occurrence?

Our tool keeps the first occurrence of each line and removes later copies. With Ignore case on, the capitalization of that first occurrence is kept.

Is the duplicate check case-sensitive?

Only if you want it to be. With Ignore case on (the default), "Apple" and "apple" count as duplicates; turn it off to treat them as different lines.

How do I sort lines alphabetically?

Paste your lines and set Sort order to A to Z, or Z to A for reverse order. Turn Remove duplicate lines off if you want to sort without removing anything.

What is natural sort order?

Natural sort reads numbers inside text as whole values, so "item2" comes before "item10". A plain alphabetical sort compares character by character and puts "item10" first.

How do I remove blank lines from text?

Turn on Remove empty lines. With Trim whitespace also on, lines that contain only spaces or tabs count as empty and are removed too.

Ready to use this tool?

Try the Remove Duplicates & Sort Lines now and simplify your workflow immediately.

G
Great Online Apps
Toggle sidebar