Remove Duplicate Lines — Deduplicate Text Online
Paste any list or block of text and delete repeated lines instantly. Keep the first occurrence or the last, with optional case-insensitive and whitespace-tolerant matching.
Lines: 0
Lines: 0
Where duplicate lines come from
Log files are the most common source. An error that fires repeatedly writes the same event line hundreds of times in sequence, drowning out the surrounding context. Exported lists from spreadsheet filters often carry duplicate rows when the same record matched multiple filter criteria. Merging two exports of the same dataset — say, a Monday pull and a Friday pull — produces doubles wherever a record appeared in both.
Version control files accumulate duplicates through separate editing sessions. A .gitignore entry added by one developer, then added again by another who did not check, is a typical example. Requirements files and package lists acquire the same pattern. Changelog and to-do files often contain a task that was copied to mark it as in-progress and never had the original removed. Web scraping produces duplicates when a paginated result set overlaps: the first item of page two is frequently the last item of page one.
How to remove duplicate lines
Paste your text into the box. The line counter at the bottom shows how many lines are present before any processing.
Choose your options. Keep first occurrence preserves the line at the position where it appeared earliest in the input. Keep last occurrence updates its position to where it appeared most recently — useful when your data was appended chronologically and the bottom of the file is more current than the top. Ignore case makes "Apple" and "apple" count as the same line. Trim whitespace makes " hello " and "hello" count as the same line.
Click Remove Duplicates. The output shows the deduplicated text. The status line reports how many lines were in the input, how many remain, and how many were removed.
A worked example
Input — six lines: apple / banana / Apple / cherry / banana / apple.
Keep first, case-sensitive: four lines remain — apple, banana, Apple, cherry. The second banana and the second apple are removed. Apple survives because it is capitalised differently from apple. Two lines removed.
Keep first, case-insensitive: three lines remain — apple, banana, cherry. Apple is now treated as a duplicate of apple and removed along with the later occurrences. Three lines removed.
Keep last, case-sensitive: four lines remain, but the positions shift. The surviving lines are ordered by their last appearance: Apple, cherry, banana, apple. The relative order among survivors always follows input order — nothing is sorted.
Real-world use cases
Keyword lists for advertising campaigns or SEO planning: uploading duplicate keywords to a platform wastes budget and distorts performance reporting. Running the list through this tool before upload costs ten seconds.
Email and subscriber lists: merging two export files from a mailing platform almost always produces duplicates. A list with duplicates charges per-send twice for the same address and skews open-rate metrics.
Dictionary and word list files: spell-check dictionaries and autocomplete vocabularies grow by appending new words over time. Periodic deduplication keeps lookup performance predictable.
Configuration files: a requirements.txt with the same package twice can cause install conflicts. A .env file with a duplicate key will be read differently by different parsers. Deduplication catches both.
SQL dump normalisation: INSERT statements for the same primary key appearing twice cause errors on import. A quick pass through this tool before running the import finds the problem without loading the file into a database.
Changelog and release notes: a release note entry that was drafted, copied for review, and then copied back often ends with the same line appearing twice. Deduplication catches it before the file is published.
Keep first versus keep last
Keep first preserves the line at its earliest position. Use this for priority-ordered lists, for canonical word lists where the first definition is the authoritative one, and for any sorted input where the top occurrence is the correct one.
Keep last reflects the most recent entry when data was appended in chronological order. A server log where the newest event is at the bottom of the file, or a changelog where the most recent entry comes last, should use keep last so the current state survives when older duplicates are removed.
Neither mode reorders surviving lines. The output is always a subsequence of the input in the original sequence. Duplicates are dropped; everything else stays where it was.
Matching options: case and whitespace
Case-sensitive matching is the default. "Error" and "error" are treated as different lines. Use this when capitalisation carries meaning — proper names, file paths that are case-sensitive on the target filesystem, or any list where casing is part of the identity of the value.
Case-insensitive matching is the right choice for keyword lists, email addresses, and anything typed by multiple people who may not be consistent about capitalisation. The output line uses the casing of the surviving occurrence: if you chose keep first and the first occurrence was "Apple", the output shows "Apple" even though later occurrences were "apple".
Trim whitespace matching treats " banana " and "banana" as the same line. The casing and padding of the surviving occurrence are preserved in the output. If you want clean output regardless of which occurrence survives, run the text through the remove extra spaces tool before deduplicating.
Empty lines and blank-only lines
Multiple consecutive empty lines are treated as duplicates of each other by default. Three blank lines in a row become one. This is usually the right behaviour for formatted text where blank lines are used as paragraph separators.
A line containing only spaces is not the same as an empty line unless trim whitespace is enabled. With trim enabled, " " is treated as "" — an empty line — and is deduplicated with other empty or blank-only lines accordingly.
Your text never leaves your browser
Deduplication is handled by a JavaScript Set running in the current tab. Nothing is uploaded, nothing is logged, and nothing persists after you close the page. For sensitive lists — email addresses, passwords, internal identifiers — this tool is safe to use because the data travels nowhere.
If you need to verify this yourself: open the browser network panel before pasting, then click Remove Duplicates. No outgoing request will appear.
Related tools on this site
If lines contain extra spaces that should be stripped before comparison, run the text through the remove extra spaces tool first, then deduplicate.
If the problem is invisible characters rather than duplicate lines, the invisible character remover handles zero-width spaces and Unicode control characters with a per-character report.
For removing unwanted line breaks from prose before deduplicating, use the remove line breaks tool. For cleaning up symbols from the deduplicated output, the remove special characters tool handles that step.
Preserving order versus sorting before deduplication
The default behaviour of any deduplication step is to keep lines in the order they first appeared. That order-preserving approach is almost always what you want when the list has meaningful sequence — a ranked keyword list, a prioritised task list, a log file where time order matters. Removing duplicates from a ranked list without touching the ranking means the surviving lines stay at their original positions. The first occurrence wins, and everything after the input is still in the same top-to-bottom sequence the original had. Nothing gets reshuffled just because duplicates were removed.
Sorting before deduplication is a different operation with a different outcome. If you sort the lines alphabetically first, then remove duplicates, the result is a clean alphabetical list with no repeated lines. That is genuinely useful for word lists, dictionary files, and any set where you only care about membership and not sequence. The trade-off is that the original order is gone. A keyword list that was ranked by search volume becomes a flat alphabetical list with no indication of priority. For SEO keyword lists or advertising audiences, losing that rank means losing the information that drove the order in the first place. Use sort-then-deduplicate only when you are sure the sequence is arbitrary.
A third variant is deduplication that keeps the last occurrence instead of the first. This is order-preserving in the sense that survivors stay in their original relative positions, but it is biased toward the bottom of the input rather than the top. Use it when your data was built by appending updates over time and the most recent entry is at the end. A config file that was edited by multiple people, where later entries should win when the same key appears twice, is a case where keep-last gives the correct result. The practical difference between keep-first and keep-last only shows up when duplicates are spread across the file rather than adjacent. For adjacent duplicates, both modes produce the same output.
Deduplication in practice: email lists, keyword tables, and log files
Email lists from two separate exports almost always overlap. Say you export your active subscribers on Monday — 4,200 addresses — and export again on Friday after a campaign — 4,350 addresses. The 4,200 Monday addresses are all still present in the Friday file. Merging the two gives you 8,550 lines, but only 4,350 are unique. Sending to the merged list without deduplication charges your email platform twice for the 4,200 addresses that appeared in both files and skews your open-rate reporting by counting those recipients twice in the denominator. Running the merged list through a deduplication step first costs ten seconds and prevents both problems. Case-insensitive matching is important here because jane@example.com and Jane@example.com are the same mailbox. Trim whitespace matching is equally important because a copy-paste error that adds a trailing space produces what looks like a new address but is not.
Keyword tables for SEO or advertising are another common case. A keyword research session might pull terms from three different tools — a volume tool, a competitor gap analysis, and a suggestions list. Each export contains some of the same high-value terms the others found. Merging all three into one spreadsheet column and deduplicating gives you a clean union. The caveat is that the three tools may have formatted the same phrase differently: one might write remove duplicate lines with two spaces between words, another might write it with a trailing space, and a third might capitalise the first letter. Case-insensitive matching and trim-whitespace matching together handle all three variants and treat them as the same keyword. Without both options enabled, those three slightly different strings all survive deduplication as if they were distinct terms, inflating your keyword count and causing you to bid on the same concept multiple times.
Server log deduplication is more selective. You rarely want to remove all duplicate log lines because two identical error events at different times are genuinely distinct occurrences that should both be counted. What you usually want is to remove consecutive repeated lines — the same error that fires 500 times in a row during a transient failure, producing 500 identical lines in sequence. For that use case, run the log through this tool with keep-last enabled and look at the before-and-after line counts. If the count drops from 10,000 to 200, you know 9,800 of the lines were redundant repetitions. The surviving 200 lines represent the distinct events, and the count difference tells you roughly how severe the repetition was. For a more granular view, tools like uniq -c on Unix count consecutive duplicates and prepend the count to each unique line — useful if you want to know not just that a duplicate existed but how many times it appeared.
Frequently Asked Questions
▸Does the order of the remaining lines change?
No. The output is always a subsequence of the input in the original order. Keep first keeps lines at their earliest positions; keep last keeps lines at their most recent positions. Nothing is sorted. If lines A, B, A appear in that order, keep first produces A, B; keep last produces B, A — both in original relative sequence.
▸What counts as a duplicate?
Two lines are duplicates if their characters match exactly under the settings you chose. With case-sensitive matching, "Error" and "error" are different. With case-insensitive matching, they are the same. With trim whitespace enabled, leading and trailing spaces are removed before comparison. An empty line is a duplicate of another empty line, so three blank lines in a row become one.
▸Can I deduplicate a list with thousands of lines?
Yes. The tool uses a JavaScript Set, which handles lists of hundreds of thousands of lines without any meaningful delay. Everything runs locally in your browser. No file size limit is enforced by the tool itself — the practical ceiling is your browser tab's available memory, which is several hundred megabytes on a modern device.
▸What is the difference between case-insensitive deduplication and lowercasing the text first?
Case-insensitive deduplication removes duplicates while preserving the original casing of the surviving line. If "Apple" appears first and "apple" appears later, keep-first case-insensitive produces "Apple" in the output. Lowercasing first then deduplicating produces "apple" — the casing is gone. Use case-insensitive deduplication when you want duplicates removed but casing preserved; lowercase first when you want both effects.
▸How does the tool handle Windows line endings?
Carriage returns (U+000D) are stripped before comparison. A line ending in \r\n and a line ending in \n are treated as the same line. Neither the carriage return nor the line-ending mismatch causes a false non-duplicate. The output uses Unix line endings (\n only) regardless of what the input contained.