How to Remove Duplicate Lines From a Text File (Free, No Software)

The fastest way to learn how to remove duplicate lines in text is to paste your list into a free online duplicate line remover, click one button, and copy out the clean list. One copy of each line stays, every repeat is deleted, and the order of what is left does not change. The whole job takes seconds, and you do not need to install anything.

That is the short answer. But duplicates show up in different places — a text file, a spreadsheet, a list of emails, a keyword list for a website — and the best method depends on where your list lives. This guide covers all of them: the online tool, Excel, Google Sheets, and Notepad++, plus the traps that leave duplicates behind even when you think you have cleaned the list.

Close-up of a person reviewing a spreadsheet on a laptop in a cafe

The Fastest Way: Remove Duplicates Online in One Click

If your list is plain text — one item per line — an online tool is the simplest route. Open Toollan’s free Duplicate Line Remover, paste your text into the box, and click the button. The tool keeps the first occurrence of each line, deletes every later repeat, and shows you the cleaned list ready to copy.

Here is a small example. Paste this in:

maya@example.com
liam@example.com
maya@example.com
sofia@example.com
liam@example.com
noah@example.com

And you get this back:

maya@example.com
liam@example.com
sofia@example.com
noah@example.com

Six lines become four. The order stays the same as the original list, so the first time each item appeared is where it stays. That is how to remove duplicate lines in text with the online tool: paste, click, copy.

The online route is the right choice when your list is already text, when you do not want to open a spreadsheet for a one-minute job, or when the file is on a computer where you cannot install software. It works in any browser, on any device. The one thing it does not do is clean up the inside of a line: if a line has a trailing space or a different capitalisation, it looks like a different line to the tool. We cover that in the gotchas section below, and the Text Cleaner can tidy the spacing first if your list needs it.

How to Remove Duplicates in Excel

If your list already lives in a spreadsheet, Excel has a built-in tool for this. Microsoft’s own steps are:

  1. Select the range of cells that has the duplicates, or click any cell inside the table.
  2. On the Data tab, in the Data Tools group, click Remove Duplicates.
  3. Under Columns, tick the columns Excel should compare. Keep every column ticked to remove only rows that match completely.
  4. Click OK. Excel tells you how many duplicate values it removed and how many unique values remain.

Three things to know before you click OK. First, Excel keeps the first occurrence of each value and deletes the rest. Second, the deletion is permanent — Microsoft’s advice is to copy the original data to another worksheet before you start, because Undo is the only way back and it stops working once you close the file. Third, when a row matches on the columns you selected, Excel deletes the whole row, including data in columns you did not select. So if you compare only the email column, a row with a matching email disappears entirely, even if its other columns were different.

There is also a non-destructive route. In Excel for Microsoft 365, Excel 2024, or Excel 2021, the UNIQUE function builds a clean copy and leaves the original untouched: type =UNIQUE(A2:A500) in an empty column and the de-duplicated list spills out below. And if you want to look before you delete, Home > Conditional Formatting > Highlight Cells Rules > Duplicate Values colours the repeats without changing anything.

How to Remove Duplicates in Google Sheets

Google Sheets has the same two options: a built-in cleanup tool that deletes, and a formula that copies.

The cleanup tool: select your data, then go to Data > Data cleanup > Remove duplicates. Tick Data has header row if your first row holds column names, choose the columns to compare, and click Remove duplicates. Sheets deletes the repeated rows in place and reports how many it removed.

The formula: in an empty cell, type =UNIQUE(A2:A500). Sheets returns a clean list next to your data, in the order each value first appeared, and the original range stays exactly as it was. Because it is a formula, the clean list updates automatically if you change the source data — useful for a list that keeps growing.

One detail worth knowing: =UNIQUE(range, FALSE, TRUE) does something different. The third argument, set to TRUE, returns only the values that appear exactly once. That means every value with a duplicate is dropped entirely, not just its extra copies. It is a handy trick when you want to find the items that are truly unique, but it is a nasty surprise if you expected one copy of everything.

Sheets also has a Data > Data cleanup > Trim whitespace option, which strips leading and trailing spaces from the selected cells. Run it before you remove duplicates if your list was pasted from somewhere else — a trailing space is the most common reason a “duplicate” survives. For more on getting the most out of Google’s apps, see our Google Workspace tips for beginners.

Financial documents and charts with a magnifying glass on a desk

How to Remove Duplicates in Notepad++

Notepad++ is a free text editor for Windows, and it is a good fit when your list is a plain text file — a log file, a list of URLs, a keyword file — rather than a spreadsheet. It handles large files without slowing down, and the steps are short:

  1. Open the file in Notepad++.
  2. Select the lines you want to clean, or press Ctrl + A to take the whole document.
  3. Go to Edit > Line Operations > Remove Duplicate Lines.

The command keeps the first occurrence of each line and removes later repeats, wherever they appear in the file, and the order of the lines that remain is unchanged. There is also a second command in the same menu, Remove Consecutive Duplicate Lines, which only removes a repeat when it sits directly below the original. That one is useful after sorting: run Edit > Line Operations > Sort Lines Lexicographically Ascending first to group identical lines together, then remove the consecutive duplicates.

Notepad++ also has a Blank Operations submenu under Edit with Trim Trailing Space, which strips spaces from the end of every line. Run it before the dedupe step and you catch the duplicates that differ only by an invisible space at the end of the line.

If you work on the command line instead, two one-liners do the same job on Linux and macOS. sort -u file.txt removes duplicates but sorts the file. awk '!seen[$0]++' file.txt removes duplicates while keeping the original order. Both are worth knowing if you clean lists often, but for a one-off job the online tool or Notepad++ is faster.

Keep the First Occurrence or the Last? (What “Remove Duplicates” Actually Does)

Every method above keeps the first occurrence and deletes the later ones. That is the standard behaviour in Excel, Google Sheets, Notepad++, and most online tools, and it is the right default most of the time: the first time an item appears is usually the original, and the repeats are the accidents.

Sometimes, though, the last occurrence is the one you want. A list of email addresses where the newest sign-up is at the bottom, for example, or a log file where the latest entry for a user is the current one. If that is your situation, reverse the list first (sort it in reverse order, or flip it), remove the duplicates, and then reverse it back. That way the copy that survives is the one that was last in the original order.

One more thing the tools do not do: they do not tell you which lines were duplicates unless you compare before and after. If you need a record, save a copy of the original list first. That is good practice anyway, because every method here except the UNIQUE formula changes your data in place.

Common Gotchas: Extra Spaces, Case Differences, Blank Lines

Most of the time, a “duplicate” that survives cleaning is not really a duplicate to the tool — it differs in some way you cannot see. Here are the usual suspects.

Extra spaces. maya@example.com and maya@example.com  (with a trailing space) are two different lines as far as any dedupe tool is concerned. The same goes for a space at the start of a line, or two spaces between words instead of one. Trim the whitespace first: Sheets has Trim whitespace, Notepad++ has Trim Trailing Space, and the Text Cleaner can tidy a pasted list before you dedupe it.

Case differences. Some tools treat Apple and apple as different lines, and some do not. Notepad++ is case-sensitive, so both survive. If capitals should not matter for your list, convert everything to the same case first — lowercase is the usual choice for email addresses, which are case-insensitive in practice.

Blank lines. Empty lines count as lines too. A file with five blank lines scattered through it will keep one blank line after deduping, and the rest disappear. That is usually what you want, but if your list uses blank lines as separators between groups, dedupe will collapse them. Remove the blank lines first, dedupe, and add your separators back afterwards if you need them.

Hidden characters. Text copied from a PDF or a web page can carry invisible characters — non-breaking spaces, tabs, or carriage returns — that make two lines look identical on screen while being different underneath. If a duplicate stubbornly survives, paste the lines into a plain-text editor and turn on “show all characters” to see what is really there.

Different spellings. No dedupe tool catches near-duplicates. Jon Smith and John Smith are different lines, and so are acme.com and www.acme.com. If your list has spelling variants, you need to standardise them by hand first, or accept that the tool will only catch exact matches.

Close-up of hands typing on a laptop in a bright, minimalist room

Frequently Asked Questions

How to remove duplicate lines in text without software?

Paste the text into a free online duplicate line remover, click the button, and copy the cleaned list back out. It runs in your browser, so there is nothing to install. On Windows, Notepad++ is a free download if you would rather work on the file itself.

Does removing duplicates keep the first or the last occurrence?

Almost every tool keeps the first occurrence and deletes the later repeats: Excel, Google Sheets, Notepad++, and most online removers all work this way. To keep the last occurrence instead, reverse the list, remove duplicates, and reverse it back.

Why do some duplicates remain after I remove them?

Usually because the lines are not exact matches. A trailing space, a capital letter, a tab, or a hidden character makes two lines different to the tool even when they look the same on screen. Trim whitespace and standardise the case before you dedupe.

Can I remove duplicates without deleting the original list?

Yes. In Google Sheets or Excel, use the UNIQUE formula (=UNIQUE(A2:A500)) to build a clean copy in another column while the original stays untouched. With the online tool or Notepad++, just keep a copy of the original file before you start.

Overhead view of laptops, charts, and reports used for data analysis on a desk

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top