Remove Duplicate Lines

Delete repeated lines from a list while keeping the original order, with options for case, spaces and blank lines.

7
Lines before
5
Lines after
2
Duplicates removed
2
Repeated lines

What this tool does

Paste a list and every line that already appeared earlier is dropped, while the remaining lines stay in their original order. Nothing is sorted, so the output reads the same way as the input, just without the repeats.

That order-preserving behavior is the main difference from the usual spreadsheet or command-line routes. Sorting a column and removing adjacent duplicates works, but it shuffles your list. Here the first copy of each line stays where it was, which matters for ranked lists, log files, playlists and anything else where position carries meaning.

Key takeaways

  • Order is preserved: only the later repeats are removed.
  • Ignore case treats Apple and apple as the same line.
  • Trim spaces ignores invisible leading and trailing spaces, a common cause of missed duplicates.
  • Keep last occurrence keeps the final copy of each line instead of the first.
  • Everything runs in your browser; your list is never uploaded.

A worked example

The tool opens with this seven-line list: apple, banana, Apple, cherry, banana,   cherry, date, where the second cherry starts with two spaces. Each row of the table below is the real output for a different combination of options.

OptionsOutputLines afterRemoved
Default (trim on, case-sensitive, keep first)apple, banana, Apple, cherry, date52
Ignore caseapple, banana, cherry, date43
Trim offapple, banana, Apple, cherry,   cherry, date61
Ignore case, keep lastApple, banana,   cherry, date43

Input: 7 lines. With trimming off, the indented cherry no longer matches the plain one, so only the repeated banana is removed.

Notice what keep last does. With case ignored, apple appears twice; keeping the last copy means the surviving line is Apple in the third position, not apple in the first. The same rule picks the indented cherry over the plain one. Output order still follows the input: each kept line sits where its surviving copy was.

Choosing the right options

Ignore case

Email addresses are the classic case. The part after the @ is never case-sensitive and, in practice, the part before it almost never is either, so ANA@example.com and ana@example.com reach the same inbox. In a six-address test list containing one capitalized copy of an address, the default setting kept four lines; ignoring case kept three. Leave this option off for codes, passwords, file names on Linux and anything else where capitals are meaningful.

Trim spaces before comparing

This is on by default because trailing spaces are invisible and almost always accidental. Text pasted from spreadsheets, PDFs and web pages often carries a space at the end of some lines but not others, and a strict comparison then treats two visibly identical lines as different. Trimming only affects the comparison: the line that is kept is written out exactly as it was, spaces included.

Keep all blank lines

By default a blank line is treated like any other line, so only the first one survives. That is right for a list, but it collapses paragraph spacing in prose. Tick this option to leave every blank line in place and only de-duplicate lines that contain text. With the input Intro, blank, Point A, blank, Point A, blank, End, the default keeps four lines and this option keeps six, removing only the repeated Point A.

Keep first or last occurrence

Keep first suits ranked or chronological lists where the earliest entry is the one that matters, such as the first time an error appears in a log. Keep last suits lists that are appended to over time, where the latest copy reflects the current state, such as a list of settings in which later lines override earlier ones.

What counts as a duplicate

Two lines are duplicates when they match exactly after the options you chose are applied. A few details are worth knowing:

  • Accented letters are compared in a normalized form, so an e with an accent typed as one character matches the same letter built from a plain e plus a combining accent. They look identical on screen and are treated as identical here.
  • Spaces inside a line are never ignored. New York and New  York with two spaces are different lines; run the text through a whitespace cleaner first if that matters.
  • Windows and Unix line endings are both understood. If your text uses Windows (CRLF) line breaks, the output keeps them.
  • A final line break at the end of the input is preserved, so the output can be pasted back into a file without changing how it ends.
  • Partial matches do not count. 08:01 ping and 08:02 ping are different lines even though they share a word.
Duplicate lines are not the same as duplicate records. If each line is a row of comma-separated values, two rows with the same email address but a different name are different lines and both stay. For column-based de-duplication, use a spreadsheet or convert the data first.

Common uses

  • Mailing lists: merge exports from several sources and remove the overlap before importing. Ignore case for email addresses.
  • Keyword lists: combine research from different tools without counting the same phrase twice.
  • Log files: strip repeated messages to see the distinct events, keeping the first time each one occurred.
  • Code and config: find repeated import lines, CSS selectors or entries in a .gitignore file.
  • Inventories and tags: clean up product codes, hashtags or category lists that were typed by several people.

The four counters under the tool show lines before, lines after, duplicates removed and repeated lines. Repeated lines is the number of distinct lines that appeared more than once; if one line appears five times, it counts once there but contributes four to duplicates removed.

Everything happens in your browser. Your list is processed on your own device with JavaScript. Nothing is uploaded, stored or logged, so you can safely paste customer emails, internal data or private notes. Closing the tab discards it.

Frequently Asked Questions

Does removing duplicates change the order of my lines?

No. Lines stay in their original order and only the repeats are removed. With keep first, each line stays where it first appeared; with keep last, it stays where it last appeared.

How do I remove duplicates regardless of capital letters?

Tick Ignore case. Lines that differ only in capitalization, such as Apple and apple, are then treated as the same line and only one copy is kept, written exactly as it appeared in your text.

Why are two identical-looking lines both kept?

Usually because one has an invisible difference: a trailing space, a tab, a non-breaking space or a different number of spaces between words. Trim spaces handles the ends of lines; spaces in the middle still count, so clean those with a whitespace tool first.

What is the difference between keep first and keep last?

Both keep one copy of each line. Keep first keeps the earliest copy, which suits ranked lists and logs. Keep last keeps the latest copy, which suits lists where later entries replace earlier ones.

Are blank lines removed?

By default blank lines are de-duplicated like any other line, so one remains. Tick Keep all blank lines to leave every blank line in place, which preserves paragraph spacing in prose.

Is there a limit on how many lines I can paste?

There is no fixed limit. The tool uses a hash set, so it handles tens of thousands of lines almost instantly. Very large inputs are limited only by your browser's memory.

Can I remove duplicates and sort at the same time?

This tool deliberately keeps the original order. To sort and de-duplicate together, use the Text Sorter, which has a Remove duplicates option alongside A to Z, natural and length sorting.

How do I remove duplicates in Excel or Google Sheets instead?

Excel has Data, Remove Duplicates, and Google Sheets has the UNIQUE function or Data cleanup, Remove duplicates. Both work on columns. For a quick plain-text list, pasting here is faster and keeps line order.

Is my text uploaded anywhere?

No. All processing happens in your browser and nothing is sent to a server. You can paste private lists safely; closing the tab discards them.

Related Calculators