Like ToolFern? Prefer us as your source on Google →

Remove Duplicate Lines

Paste any list and instantly delete repeated lines, keeping either the first or last occurrence of each. Optionally ignore case, trim spaces before comparing, strip blank lines and sort A, Z.

0Input lines
0Unique lines
0Duplicates removed
0Blank lines removed

How to remove duplicate lines

  1. Paste your text into the Text with duplicate lines box, one item per line.
  2. Choose your options: Case-insensitive, Keep first or last occurrence, Trim whitespace before comparing, Remove blank lines and Sort A, Z.
  3. Click Apply to deduplicate the list. The result appears below, ready to use.
  4. Hit Copy to grab the clean, unique list for your spreadsheet, email or code.

What each option does

Choose which occurrence survives

By default the tool keeps the first time a line appears and quietly drops every later copy, so the order of your remaining unique lines is exactly the order they first showed up in your text. Switch to keep last and it drops everyearlier copy instead, keeping only the final occurrence, useful when a later row in your data is the corrected or most up to date version of an earlier one. Either mode works well for cleaning email lists, keyword lists, CSV columns, log files or any list where duplicates need to go. The live counters show how many lines went in, how many unique lines came out, how manyduplicates were removed, and (when that option is on) how many blank lines were stripped, so you can see the cleanup at a glance.

Frequently asked questions

Does it keep the first or last duplicate?

Either, it's your choice. Pick “Keep the first occurrence” and every later repeat is dropped, or pick “Keep the last occurrence” and every earlier repeat is dropped instead.

Does trimming change the text of the line that's kept?

No. Trimming before comparing only affects which lines count as duplicates. The line that survives keeps its own original spacing. Tick “Remove blank lines” separately if you want whitespace-only lines gone entirely.

Can I deduplicate a very long list?

Yes. Paste as many lines as you like, the only limit is your browser's available memory.

Which copy of a duplicate is kept?

You choose. Keep the first occurrence and every later repeat is dropped, so the original order of unique lines is preserved. Keep the last occurrence and every earlier repeat is dropped instead, so the surviving line sits at the position of its final appearance. Either way, sorting A, Z is optional and off by default.

What does case-insensitive do?

When ticked, lines that differ only in capitalisation, such as “Apple” and “apple”, are treated as the same line. The line that's kept still shows its own original capitalisation, only the comparison ignores case.

Does trimming before comparing change my output?

No. “Trim whitespace before comparing” only affects how lines are matched, so “foo” and “foo ” with a trailing space are treated as duplicates. The line that survives keeps its own original spacing, it is not trimmed. Use “Remove blank lines” separately if you want whitespace-only lines stripped out.

Related: sort text lines · clean up messy text · count words & characters

Found this useful? Share it