Skip to content

Remove duplicate lines

Paste a list with one item per line. Each line is kept once, in the place where it first shows up, ready to copy.

Keep
Ignore
Result
More options: compare one column, header line
Compare

Your list stays in this browser. Nothing is uploaded.

Advertisement
A column of paper strips running through a sieve, with the repeated strips caught and set aside

Why some copies are not found

Two lines only count as copies when every character matches. A space at the end of a line is invisible, and "Milk" and "milk" differ in one letter. Text from a web page often has a no-break space instead of a normal one. Some sites add a zero width space that does not show at all.

The letter é can be stored two ways: as one character, or as e plus an accent mark. Tick "Invisible characters" and the tool treats both forms as one letter. It also skips zero width characters and reads odd spaces as normal spaces. Line ends from Windows (CRLF) and from Linux or Mac (LF) are read the same way.

When a looser setting would find more copies, the note under the result says how many. To see which hidden characters a line holds, paste it into the invisible character tool. To clean the text itself, use the text cleaner.

Duplicates in one column of a CSV file

Rows of a CSV file can differ in one value and still be the same person or product. Open More options, set Compare to "one column" and give its number. The whole row stays or goes. Tick "Keep the first line on top" so the row of column names is left alone.

This is where "Last copy" helps. Say people signed up twice with the same email address. The last row may hold their new city, so "Last copy" keeps the newest row in its place. The tool finds the separator by itself: a tab, a comma, a semicolon or a bar. For a grid view of the whole table, open the CSV editor.

Remove duplicates in Excel and Google Sheets

In Excel, select the column, then go to Data, Data Tools, Remove Duplicates. Pick the columns to compare and click OK. Excel keeps the first copy and deletes the other rows.

In our test with Excel for Microsoft 365, Remove Duplicates and the UNIQUE function both ignored case, so "Apple" and "apple" were one value. A space at the end still made a value different. Excel also compares what a cell shows, so one date in two formats counts as two values. Microsoft's guide to removing duplicate values has the details.

In Google Sheets, select the data and go to Data, Data cleanup, Remove duplicates. Cells that differ only in letter case still count as copies there. To also catch copies that differ only in spaces, run Data cleanup, Trim whitespace first.

Notepad++, VS Code and Word

Notepad++ has Edit, Line Operations, Remove Duplicate Lines. It keeps the first copy of each line. Remove Consecutive Duplicate Lines only removes a copy that sits right below the line it repeats.

In VS Code, press Ctrl+Shift+P and run "Delete Duplicate Lines". It keeps the first copy and compares lines exactly, so case and spaces count.

Word has no command for this. Home, Sort puts the paragraphs in order, so copies end up next to each other and you can delete them by hand. For a long list, paste it here and paste the result back into Word.

Advertisement

Remove duplicate lines on the command line

On Linux and macOS, sort -u sorts the lines and keeps one of each. uniq only merges copies that sit right next to each other, so people sort first. Both lose the order of the list. The awk line keeps the order, because it prints a line only the first time it sees it.

CommandWhat it does
sort -u file.txtSorts and keeps one copy of each line
sort -f -u file.txtThe same, but Apple and apple are one line
awk '!seen[$0]++' file.txtKeeps the first copy, in the original order
tac file.txt | awk '!seen[$0]++' | tacKeeps the last copy, in the original order. macOS has no tac, so use tail -r there.
sort file.txt | uniq -cCounts how often each line appears
sort file.txt | uniq -dShows only repeated lines, once each
sort file.txt | uniq -uShows only lines with no copy
Get-Content file.txt | Select-Object -UniquePowerShell: keeps the first copy in order, case matters
Get-Content file.txt | Sort-Object -UniquePowerShell: sorts and ignores case

A file saved on Windows has a carriage return at the end of each line. sort and uniq then see "apple" with and without it as two lines, so convert the line ends first. The uniq manual lists more options. Checked with GNU coreutils 8.32 and Windows PowerShell 5.1, November 2026.

Frequently asked questions

How do I remove duplicate lines and keep the original order?

Paste the list in the top box. The tool keeps the first copy of each line in its place and removes the later ones, so the order stays as it was. For A to Z order, change Order under the result or use sort lines.

How do I remove both copies of a duplicate line?

Click "Only lines with no copy" next to Keep. Every line that shows up more than once is removed, the first copy too.

How can I see only the duplicate lines?

Click "Only repeated lines" for one copy of each. The Repeated tab also shows how often each one appears and on which lines.

How do I count how many times each line appears?

Tick "Show how often". Each line of the result gets its count in front, with a tab after it, so the counts land in their own column in a spreadsheet. Set Order to "most common first" to get a top list.

Why are some duplicate lines not removed?

They differ in a way you cannot see, like case, a space at the end or an invisible character. The comparison is case sensitive until you tick Case next to Ignore.

Does it work with very large lists?

Yes. A list of 100,000 lines takes about one to two seconds on a normal computer. The list stays in your browser and is not uploaded.

  • Text editorWrite and edit text online for free, then convert it to fancy fonts, bold, frames and ASCII art in one click.
  • CSV editorOpen a CSV file in a grid, fix cells, sort, add or delete rows and save it as CSV, Excel, JSON or a Markdown table.
  • Word counterCount words, sentences and paragraphs as you type.
  • Case converterPaste text and change it to UPPERCASE, lowercase, Sentence case or Title Case in one click.
  • NotepadKeep several notes in one place.
  • Table editorOpen an Excel or OpenDocument file, or paste cells from a spreadsheet, and edit them in a grid.

↑ ↓ to choose, Enter to open, Esc to close