Why use Remove Duplicate Lines
This tool keeps the first copy of every line and deletes each later repeat, without sorting unless you ask for it. The sample list of 7 fruit names contains apple and banana twice, so it comes back as 5 unique lines with 2 removed. Four checkboxes decide what counts as a repeat: Ignore letter case treats Apple and apple as the same line, Ignore leading/trailing spaces strips spaces and tabs from both ends before comparing, Keep blank lines controls whether empty lines survive, and Sort the result A→Z orders the output alphabetically. The first two are on by default. The Summary shows Original lines, Unique lines and Removed, and the result can be copied or downloaded as unique-lines.txt.
What each option does to the same list
Input, 9 lines: Apple, apple, [space]apple, Banana, a blank line, banana[space], Cherry, a blank line, APPLE.
| Settings | Result | Unique lines | Removed |
|---|---|---|---|
| Defaults (ignore case and end spaces) | Apple, Banana, Cherry | 3 | 6 |
| Ignore letter case off | Apple, apple, Banana, banana, Cherry, APPLE | 6 | 3 |
| Ignore leading/trailing spaces off | Apple, [space]apple, Banana, banana[space], Cherry | 5 | 4 |
| Both off (exact match) | Apple, apple, [space]apple, Banana, banana[space], Cherry, APPLE | 7 | 2 |
| Defaults plus Keep blank lines | Apple, Banana, one blank line, Cherry | 4 | 5 |
| Ignore letter case off, Sort the result A→Z on | apple, Apple, APPLE, banana, Banana, Cherry | 6 | 3 |
Removed includes blank lines that were dropped, not only repeats. With Keep blank lines on, blank lines are deduplicated like any other line, so only the first one survives.
Worked examples: emails, logs and URLs
Merging two email lists
Sam@example.com, sam@example.com, jo@example.com, [space]jo@example.com[space], a blank line, SAM@EXAMPLE.COM. Default settings.
Sam@example.com and jo@example.com. Original lines 6, Unique lines 2, Removed 4.
With Ignore letter case unticked the same list keeps 4 lines, because the three spellings of Sam's address count as different.
Finding the distinct messages in a log
ERROR timeout, INFO ok, ERROR timeout, WARN slow, ERROR timeout, INFO ok. Default settings.
ERROR timeout, INFO ok, WARN slow. Original lines 6, Unique lines 3, Removed 3.
Lines that start with a timestamp never match each other. Strip the timestamp column first.
A URL list
https://example.com/page, https://example.com/page/, http://example.com/page, https://example.com/page. Default settings.
Three lines kept, 1 removed.
Matching is on the text of the line. A trailing slash or http against https makes a different line, even if the addresses load the same page.
City names in mixed case, sorted
London, paris, LONDON, Berlin, Paris, london. Sort the result A→Z ticked.
Berlin, London, paris. Original lines 6, Unique lines 3, Removed 3.
paris stays in lower case because that was the first spelling in the list.
Lookalike lines that are not merged
Each pair below was tested with the default settings and stayed as two lines.
| Difference | Example pair | How to fix it first |
|---|---|---|
| Two spaces inside the line | new[2 spaces]york / new york | Run the list through Remove Extra Spaces |
| Non-breaking space from a web page | new[nbsp]york / new york | Replace the odd space with a normal one using Find and Replace |
| Tab against a space | apple[tab]red / apple red | Replace tabs with spaces |
| Curly against straight apostrophe | it’s / it's | Replace curly quotes with straight ones |
| Accent stored as a separate mark | cafe + combining accent / café | Retype the accented letter in one of the lines |
| Trailing slash or different scheme in a URL | example.com/page / example.com/page/ | Decide on one form and replace the other |
| Several items on one line | apple, banana, apple | Put each item on its own line first |
Windows line endings are not a problem while Ignore leading/trailing spaces is ticked, because the carriage return at the end of each line is stripped before comparing. With that option unticked, a final line with no line break after it will not match an earlier copy from a Windows file.
How to remove duplicate lines in other programs
The same job in tools you may already have open.
| Program | How | Keeps original order |
|---|---|---|
| Excel | Select the column, then Data > Remove Duplicates | Yes |
| Google Sheets | Data > Data cleanup > Remove duplicates, or the formula =UNIQUE(A2:A) | Yes |
| Notepad++ | Edit > Line Operations > Remove Duplicate Lines | Yes |
| VS Code | Select the lines, open the Command Palette and run Delete Duplicate Lines | Yes |
| Sublime Text | Edit > Permute Lines > Unique | Yes |
| Linux or macOS terminal | sort -u file.txt | No, output is sorted |
| Linux or macOS terminal | awk '!seen[$0]++' file.txt | Yes |
| Windows PowerShell | Get-Content file.txt | Select-Object -Unique | Yes |
| Python | list(dict.fromkeys(lines)) | Yes |
The uniq command on its own only removes repeats that are next to each other, which is why it is normally used after sort.
Sorting, blank lines and large lists
Sorting is a separate step from deduplicating and is off by default, because order often carries meaning: a log is chronological, a keyword list may be ranked, a playlist is sequenced. When Sort the result A→Z is ticked, the unique lines are ordered with a plain alphabetical comparison. Upper and lower case versions of a word sit together, but numbers are compared as text, so 10 and 100 come before 9 and item10 comes before item2. For numeric or natural ordering, deduplicate here and then use the Sort Lines tool.
Blank lines are removed unless Keep blank lines is ticked. Even then only one blank line is kept, since every blank line is a duplicate of the first, so this option is for keeping a single separator and not for preserving paragraph spacing.
The work is done in your browser by checking each line against a set of lines already seen, which takes one pass however long the list is. Lists of tens of thousands of lines are handled comfortably. Because nothing is uploaded, it is suitable for subscriber exports and other lists you would not want to send to a server.
Step by step
- 1
Paste your list into Lines, one item per line.
- 2
Leave Ignore letter case ticked to merge Apple and apple, or untick it when case matters, as it does for passwords, hashes and file paths.
- 3
Leave Ignore leading/trailing spaces ticked unless indentation is part of the data.
- 4
Tick Keep blank lines to retain an empty line as a separator, and Sort the result A→Z if order does not matter.
- 5
Check Removed in the Summary, then copy the Result or download unique-lines.txt.