Remove Duplicate Lines: Free Online Tool

Paste a list or drop a text file. Get every line once, sorted if you like, with duplicate URLs recognised even when they’re written differently. Free, no sign-up.

Updated

Runs entirely in your browser. Nothing you paste or open is uploaded.

Options

0 lines in0 unique0 duplicates removed

How to Remove Duplicate Lines

  1. Paste your list or drop a file

    Paste text into the input box, one item per line, or drop a .txt or .csv file on the drop area. A file is read on your computer; nothing is sent anywhere.

  2. Choose how lines are compared

    Leave “Trim whitespace” and “Ignore empty lines” on for most lists. Turn on “Ignore case” if “Apple” and “apple” should count as the same line. Turn on “URL mode” for lists of links.

  3. Pick which copy to keep and how to sort

    Keep the first copy to preserve the original order, or the last copy if later entries are more up to date. Leave sorting on “Keep original order”, or sort lines alphabetically A–Z, Z–A, naturally (2 before 10) or by length.

  4. Check the counts

    The result appears in the output box with three numbers: lines in, unique lines and duplicates removed. Press “Show duplicates” to see which lines repeated and how many times.

  5. Copy or download the result

    Press Copy to put the cleaned list on your clipboard, or Download to save it as a .txt file. Short lists update as you type; for very large inputs press “Remove duplicates” to run it.

How This Duplicate Line Remover Works

The duplicate line remover splits your text at every line break (Windows CRLF, Unix LF and old Mac CR are all recognised) and builds a comparison key for each line. The key is the line itself, adjusted by the options you picked: trimmed if trimming is on, lowercased if case is ignored, and normalised if URL mode is on. The first time a key appears, that line is kept. Every later line with the same key is counted as a duplicate and dropped.

Lookups use a JavaScript Map (a hash table), so a million lines take about a second, not minutes. Large inputs run in a Web Worker, a background thread, so the page stays responsive while a progress bar shows how far it has got.

Your text never leaves your device. The page sends nothing you paste or drop over the network, stores nothing and logs nothing. Close the tab and the list is gone.

  • Order of operations: split into lines → trim (optional) → drop empty lines (optional) → build the key (URL mode, then case) → keep first or last → sort (optional).
  • The output always shows the original line, not the key. In URL mode, “https://www.example.com/page/” stays exactly as you typed it; it just also stands for the other versions of that link.

What Counts as a Duplicate Line?

A duplicate line is a line whose content is identical to an earlier line, character for character. “Apple” and “apple” differ in case. “apple” and “apple ” differ by a trailing space you cannot see. Text copied from a web page may contain a non-breaking space (U+00A0) instead of an ordinary one. These look the same on screen and are still different strings.

That is why a dedupe tool needs options. Trimming removes spaces, tabs and other whitespace at the start and end of each line, including non-breaking spaces, because JavaScript’s trim() follows the Unicode definition of whitespace. Ignoring case compares lowercased copies. Neither option changes the words in the middle of a line: “New York” and “New York” (two spaces) are still different.

Removing duplicates, sorting and finding duplicates are three separate jobs. Unix tools blur them because uniq only removes repeats that sit next to each other, so you sort first. This tool removes duplicates wherever they are, sorts only if you ask, and lists the repeats in the “Show duplicates” view.

OptionWhat it doesExample it merges
Trim whitespaceIgnores spaces and tabs at the start and end of a line, and outputs the trimmed line“apple” and “ apple ”
Ignore caseCompares lines as if they were all lowercase; keeps the capitalisation of the copy it keeps“Apple”, “apple”, “APPLE”
Ignore empty linesDrops blank lines entirely. When off, blank lines are deduplicated like any other line, so many become oneRemoves every blank line
Keep firstKeeps the first copy of each line, in its original position“a b a c” → “a b c”
Keep lastKeeps the last copy of each line, in the position of that last copy“a b a c” → “b a c”
URL modeCompares links by what page they point to, not by their exact text (see the next section)“http://example.com” and “https://www.example.com/”

Examples: Deduplicating Real Lists

  • Email list merged from two sign-up forms: “[email protected]” and “[email protected] ” appear in both. Turn on Trim and Ignore case, keep first, and 2 lines become 1, keeping the original spelling “[email protected]”.
  • Tabs exported from three browser windows: “https://docs.google.com/document/d/abc/edit”, “https://docs.google.com/document/d/abc/edit#heading=h.1” and “https://docs.google.com/document/d/abc/edit?usp=sharing”. URL mode merges the first two (the fragment is ignored). The third keeps its ?usp parameter because usp isn’t on the tracking list, which is the safe choice.
  • File names like “scan-2.pdf, scan-10.pdf, scan-1.pdf”: plain A–Z puts scan-10 before scan-2, because it compares character by character. Natural sort gives scan-1, scan-2, scan-10.
  • A CSV export where whole rows repeat: each row is one line, so identical rows are removed. Rows that differ in any column are kept. For duplicates in one column only, use a spreadsheet (see below).

How to Sort Lines Alphabetically (and Other Sort Options)

To sort lines alphabetically, choose “A–Z” in the sort menu. The tool uses your browser’s language-aware collation (Intl.Collator), so “apple” sits next to “Apple” and accented letters sort next to their plain versions, unlike a raw byte sort.

Natural sort treats runs of digits as numbers, so “Chapter 2” comes before “Chapter 10”. Use it for file names, version-like strings and numbered items. Sort by length puts the shortest lines first and breaks ties alphabetically, which is useful for spotting truncated entries or picking the shortest URL. Z–A is simply A–Z reversed.

How to Remove Duplicate Lines in Excel, Google Sheets, VS Code, Notepad++ and Sublime Text

Excel: select the column, then go to Data → Data Tools → Remove Duplicates. Microsoft notes that this permanently deletes the duplicate values, so work on a copy (Ctrl+Z works straight away). In Excel for Microsoft 365, Excel 2021 and Excel 2024 you can instead use a formula that leaves the original alone: =UNIQUE(A2:A1000), or =SORT(UNIQUE(A2:A1000)) to sort the result.

Google Sheets: select the range, then Data → Data cleanup → Remove duplicates, choose the columns and whether the data has a header row. Google’s help page says cells with the same value but different letter case, formatting or formulas are treated as duplicates. Data → Data cleanup → Trim whitespace removes leading and trailing spaces first, though it doesn’t trim non-breaking spaces. The formula route is =UNIQUE(A2:A), or =SORT(UNIQUE(A2:A)).

VS Code: select the lines (or nothing, for the whole file), open the Command Palette with Ctrl+Shift+P (Cmd+Shift+P on Mac) and run “Delete Duplicate Lines”. The command arrived in VS Code 1.62. “Sort Lines Ascending” and “Sort Lines Descending” are in the same palette.

Notepad++: Edit → Line Operations → Remove Duplicate Lines removes repeats anywhere in the file, and “Remove Consecutive Duplicate Lines” only removes repeats that sit next to each other. The same menu has sorts that ignore case, sort as integers or decimals, or sort by length, plus “Remove Empty Lines”.

Sublime Text: Edit → Permute Lines → Unique removes duplicates and keeps the first copy. Edit → Sort Lines (F9) sorts, and Edit → Sort Lines (Case Sensitive) is next to it.

AppWhereKeeps original orderLetter case
ExcelData → Data Tools → Remove Duplicates, or =UNIQUE()YesTreats “Apple” and “apple” as the same
Google SheetsData → Data cleanup → Remove duplicates, or =UNIQUE()YesMenu command ignores case (per Google’s help)
VS Code 1.62+Command Palette → Delete Duplicate LinesYesCase-sensitive
Notepad++Edit → Line Operations → Remove Duplicate LinesYesCase-sensitive
Sublime TextEdit → Permute Lines → UniqueYesCase-sensitive
This toolPaste or drop, options aboveYes, or sortedYour choice

Spreadsheets compare cells, not lines, and they can dedupe by one column while keeping the rest of each row. That is the right choice for CSV data where only the email or ID column should be unique.

Remove Duplicate Lines From the Command Line

On macOS and Linux, the shortest way is sort -u input.txt > output.txt. It sorts the file and keeps one copy of each line. Add -f (sort -f -u) to ignore case. Note that plain uniq only removes duplicates that are next to each other, so uniq on an unsorted file usually leaves duplicates behind; that is why you see sort and uniq together.

To keep the original order, use awk: awk '!seen[$0]++' input.txt > output.txt. It prints a line only the first time it has been seen. For a case-insensitive version, use awk '!seen[tolower($0)]++' input.txt. To keep the last copy instead of the first, reverse the file, dedupe, and reverse again: tac input.txt | awk '!seen[$0]++' | tac on Linux, or tail -r instead of tac on macOS.

To see which lines repeat and how often, run sort input.txt | uniq -c | sort -rn. To list only the lines that appear more than once, use sort input.txt | uniq -d.

In PowerShell, Get-Content input.txt | Sort-Object -Unique | Set-Content output.txt sorts and dedupes. Microsoft’s documentation says Sort-Object -Unique is case-insensitive, so “localhost” and “LOCALHOST” count as one. Get-Unique works differently: it is case-sensitive by default, only compares each item to the next one, and so needs sorted input, as in Get-Content input.txt | Sort-Object | Get-Unique. PowerShell 7.4 added a -CaseInsensitive switch to Get-Unique.

CommandKeeps original orderLetter caseNotes
sort -u fileNo, output is sortedCase-sensitiveAdd -f to ignore case
sort file | uniqNoCase-sensitiveuniq -i ignores case, uniq -c counts
uniq file (unsorted)YesCase-sensitiveOnly removes adjacent repeats
awk '!seen[$0]++' fileYes, keeps firstCase-sensitiveUse tolower($0) to ignore case
Sort-Object -UniqueNo, output is sortedIgnores casePowerShell; add -CaseSensitive for a case-sensitive sort
Sort-Object | Get-UniqueNoCase-sensitiveGet-Unique needs sorted input; -CaseInsensitive from 7.4

Locale changes how sort orders lines. With a UTF-8 locale, GNU sort interleaves upper and lower case; with LC_ALL=C it sorts by byte value, so every capital letter comes before every lowercase one. Set LC_ALL=C when you need identical results on every machine.

How to Close Duplicate Tabs in Your Browser

If the duplicates you are fighting are open tabs rather than lines of text, some browsers can close them directly. Firefox added a “Close Duplicate Tabs” command in version 127: right-click a tab, or open the List all tabs menu at the end of the tab bar. Vivaldi shows a Duplicate Tabs section in its Windows panel with a “Close All Duplicate Tabs” button. Safari doesn’t close duplicates, but when you type an address that is already open it offers “Switch to Tab” instead of opening another copy.

Chrome has no built-in duplicate closer. Its Tab search (Ctrl+Shift+A, or Cmd+Shift+A on Mac) lists open tabs and filters them as you type a title or address, which makes it easy to spot and close five copies of the same page by hand. The address bar also suggests “Switch to this tab” when you type a URL that is already open. Browsers built on Chromium behave similarly, and extensions can fill the gap in all of them.

The route that works everywhere: copy your open tabs’ URLs as a list, paste them here with URL mode on, and reopen the unique pages with the bulk URL opener.

BrowserBuilt-in way to deal with duplicate tabs
Firefox 127+Right-click a tab → Close Duplicate Tabs, or List all tabs → Close Duplicate Tabs
VivaldiWindows panel → Duplicate Tabs section → Close All Duplicate Tabs
Safari (Mac)No duplicate closer; the Smart Search field offers “Switch to Tab” for an address that is already open
ChromeNo duplicate closer; Tab search (Ctrl/Cmd+Shift+A) and the “Switch to this tab” address bar suggestion
Edge, Brave, Opera, ArcNo built-in duplicate closer that we could confirm; use tab search, an extension, or this tool on a copied list of URLs

Duplicate Line Remover vs Other Methods

MethodBest forVerdict
This toolPasted lists, text files, URL lists, up to about a million linesFastest when the list is on your clipboard. URL mode is the main thing the others lack. Browser memory is the limit for huge files
Excel or Google SheetsTables where one column must be uniqueBest for row data and column-based rules. Awkward for plain text, and Sheets ignores case whether you want it or not
VS Code, Notepad++, SublimeFiles you already have open in an editorQuick and offline. Case-sensitive only, with no URL awareness
sort -u, awk, PowerShellScripts, servers, files of many gigabytesUnbeatable for size and automation. Easy to trip over uniq’s adjacent-only rule and sort’s locale
Browser feature (Firefox, Vivaldi)Duplicate open tabsOne click, but only exact-address matches, and closed tabs are gone unless you saved them
BelayTabKeeping tabs safe before you close duplicatesSaves every open tab as a session first, so closing copies is never risky. It doesn’t dedupe text lists

Limits and Troubleshooting

  • Lines that look identical aren’t merged: one probably has a hidden character, such as a zero-width space, in the middle. Trimming only handles the ends of a line.
  • Very large files: around a million lines or 50 MB works in a current desktop browser. Beyond a few hundred megabytes the tab can run out of memory. Use sort -u or awk for files that size.
  • Big results are previewed: if the output is over about 5 MB, the output box shows the first 5,000 lines to keep the page fast. Copy and Download always include every line.
  • CSV files are compared row by row. The tool doesn’t understand columns, quoted commas or headers, so a header row is treated as an ordinary line.
  • URL mode merged links you wanted separate: turn off “Strip tracking parameters”, or turn URL mode off entirely when the scheme, www. or trailing slash matters to you, for example when checking redirects.

Removing duplicates can’t be undone in the output box, but your input stays untouched until you clear it. Keep the original until you have checked the counts.

Frequently Asked Questions

How do I remove duplicate lines from a list?

Paste the list into the box above, one item per line, and the duplicate line remover shows the list with every repeated line removed. Keep “Trim whitespace” on so stray spaces don’t hide duplicates, then copy or download the result.

Is it case sensitive?

By default, yes: “Apple” and “apple” are different lines. Turn on “Ignore case” to treat them as the same; the tool keeps the capitalisation of whichever copy it keeps.

Does it keep the original order?

Yes. With sorting set to “Keep original order”, lines stay where they were and only the later copies are removed. Choose “Keep last” to keep each line at the position of its final appearance instead.

How many lines can it handle?

About a million lines, or files around 50 MB, in a current desktop browser. The work runs in a background Web Worker with a progress bar, so the page doesn’t freeze. For files of several gigabytes, use sort -u or awk on the command line.

How do I remove duplicate URLs that are written differently?

Turn on URL mode. It treats http and https, www., trailing slashes, default ports, #fragments, host letter case and query parameter order as the same link, and can also ignore tracking parameters such as utm_source, fbclid and gclid.

How do I sort lines alphabetically?

Choose “A–Z” in the sort menu and the output is sorted alphabetically after duplicates are removed. Choose “Natural” if your lines contain numbers, so item 2 comes before item 10.

Is my text uploaded anywhere?

No. Everything runs in your browser, including files you drop. Nothing is sent to a server, stored or logged, and closing the tab discards the list.

Why does uniq not remove all duplicates?

Because uniq only compares each line with the one directly before it. Sort the file first (sort file | uniq), use sort -u, or use awk '!seen[$0]++' file to remove duplicates anywhere while keeping the original order.

How do I close duplicate tabs in Chrome?

Chrome has no built-in button for it. Use Tab search (Ctrl+Shift+A, or Cmd+Shift+A on Mac) to find copies and close them, or use an extension. Firefox 127 and later has a Close Duplicate Tabs command in the tab menu, and Vivaldi has one in its Windows panel.

Related

Keep Your Tabs Safe, Too

BelayTab saves and snapshots your tabs automatically, in every browser. Free.