Skip to main content
DL

Duplicate Line Remover

Remove duplicate lines from a list, with case-sensitivity, trimming and keep-first/keep-last controls.

Did you like the tool? Thanks!
Share:


How to Use Duplicate Line Remover

Paste a list with one item per line, and duplicate lines are removed instantly. Choose whether comparison is case-sensitive, whether each line is trimmed before comparing, and whether to keep the first or last occurrence of a repeated line. A stat line reports how many duplicates were removed and how many unique lines remain. Runs entirely in your browser.

About Duplicate Line Remover

Lists accumulate duplicates constantly: an email list built up over several exports, a set of URLs scraped from different pages, a list of tags or keywords typed by different people at different times, or a CSV column pasted into a text box for a quick check. Manually scanning a long list for repeats is slow and error-prone, especially when two "duplicate" entries differ only by capitalization or a stray trailing space that is easy to miss visually. This tool treats each line of the input as one list item and removes repeats according to rules you control, rather than a single fixed definition of "duplicate." The case-sensitive comparison toggle controls whether "Apple" and "apple" are treated as the same entry or two different ones. It defaults to on (case-sensitive), meaning "Apple" and "apple" are kept as separate lines unless you turn it off — this matches how most programming contexts and exact-match use cases (like comparing exact string values from a database) expect duplicates to be judged. Turning case-sensitivity off is useful for lists where capitalization is inconsistent but semantically meaningless, like a list of email addresses or tags where "Marketing" and "marketing" really do mean the same thing. The trim-before-comparing toggle controls whether leading and trailing whitespace on a line is ignored when checking for duplicates. It defaults to on, because trailing whitespace is one of the most common invisible causes of a "duplicate" not being caught by a naive exact-match comparison — a line copied from a spreadsheet cell often carries a trailing space or tab that is visually indistinguishable from a clean line but would otherwise prevent two identical-looking entries from being recognised as duplicates. Importantly, trimming here only affects the *comparison* — the lines that remain in the output keep their original content exactly as typed, including any leading/trailing whitespace they had. This is a deliberate choice: the tool's job is to decide which lines are duplicates of each other, not to silently rewrite the content of the lines you keep. The keep first / keep last choice matters whenever the different copies of a "duplicate" line are not byte-for-byte identical after the whitespace/case rules are applied for comparison but there was more than one occurrence in the raw input — practically, it decides the output's line order and which literal occurrence (with whichever original spacing/casing it happened to have) survives into the result. Keep First scans top to bottom and keeps the earliest occurrence of every distinct line, dropping every later repeat; the surviving lines therefore appear in their original top-to-bottom order. Keep Last does the mirror image: it scans and keeps the latest occurrence of every distinct line, dropping every earlier repeat — the result still comes out in ascending original order, but wherever a line repeated, the version and position that survives is the last one in the original list rather than the first. The stat line beneath the controls reports exactly how many lines were removed as duplicates and how many unique lines remain, giving an at-a-glance summary without needing to manually count the before/after line totals yourself.

Details & Tips

How duplicate detection works: the input is split into lines. For each line, a comparison key is built by optionally trimming leading/trailing whitespace (if "trim each line" is checked) and optionally lowercasing (if "case-sensitive comparison" is unchecked). Lines whose comparison key has already been seen are treated as duplicates and removed from the output; the very first line with each unique key is always the one that establishes that key as "seen." The output always contains the exact original text of whichever line was kept — trimming and case-folding are used only to decide what counts as a match, never applied to rewrite the kept line's actual content. Keep First vs Keep Last: Keep First scans the list from top to bottom, keeping each line the first time its comparison key appears and discarding every later repeat of that key — output order matches the original top-to-bottom order. Keep Last scans conceptually from the bottom, keeping each line the last time its comparison key appears (i.e., discarding every earlier repeat) — the output is then restored to ascending original order, but the literal line content and position that survives for each repeated key is the last occurrence in the original input, not the first. Worked example — input (case-sensitive ON, trim ON, keep first): ``` apple Banana apple cherry Banana ``` Comparison keys (case-sensitive, trimmed): apple, Banana, apple, cherry, Banana. "apple" (line 3) and "Banana" (line 5) are duplicates of earlier lines. Output: `apple`, `Banana`, `cherry ` (3 unique lines, 2 duplicates removed) — note `cherry ` keeps its trailing space in the output even though trimming was used for comparison. Worked example — same input, case-sensitive OFF: comparison keys become apple, banana, apple, cherry, banana — identical duplicate detection in this example since the only case difference ("Banana" vs "Banana") was already an exact match; turning case-sensitivity off changes results when entries differ only by letter casing, e.g. "Apple" vs "apple" would now also be merged into one. Worked example — same input, keep last instead of keep first: the surviving "apple" is line 3 (not line 1) and the surviving "Banana" is line 5 (not line 2). Because Keep Last restores ascending order by the *surviving* line's original position, and the surviving "Banana" now sits after the surviving "cherry ", the output order changes to `apple`, `cherry `, `Banana` — different from the keep-first output order of `apple`, `Banana`, `cherry `. This reordering effect (not just a change in which copy survives) is an easy detail to miss when switching from Keep First to Keep Last. The stat line format is: "Removed N duplicate line(s), M unique remaining" — N is the count of lines dropped as duplicates, M is the final output line count. Blank lines are treated like any other line and can be duplicates of each other (multiple blank lines collapse to one, if trimming is on, since a trimmed blank line's comparison key is an empty string in every case).

Frequently Asked Questions

Does trimming a line before comparing change the line in the output?
No, trimming only affects how duplicates are detected. The line that survives in the output keeps its original content exactly as typed, including any leading or trailing whitespace it had.
What is the default comparison behaviour?
By default, comparison is case-sensitive and each line is trimmed before comparing, which means "Apple" and "apple" are treated as different lines, but "apple" and "apple " (with a trailing space) are treated as the same line.
What is the difference between Keep First and Keep Last?
Keep First keeps the earliest occurrence of each repeated line and drops later repeats. Keep Last keeps the latest occurrence and drops earlier repeats instead — useful when a later entry in your list is the more up-to-date version.
Does the output stay in the same order as the input?
The surviving lines are always ordered by their own original position (earlier lines first). Keep First and Keep Last can still produce a different overall order from each other, though, because Keep Last may cause a repeated line's surviving copy to jump to a later position than in the Keep First result — it is the position of whichever copy survives that determines order, not a fixed "same as input" order.
Are blank lines treated as duplicates of each other?
Yes, blank lines are lines like any other. With trimming on, multiple blank lines all compare equal (an empty string) and will be deduplicated down to one, unless you want to keep them, in which case turn trimming off — an untrimmed blank line with different invisible whitespace may not match another.
What does the stat line tell me?
It reports "Removed N duplicate line(s), M unique remaining" — the exact count of lines that were dropped as duplicates, and the total number of unique lines in the result.
Can I turn off case-sensitivity to merge "Marketing" and "marketing"?
Yes, unchecking "Case-sensitive comparison" makes the comparison case-insensitive, so entries that differ only by letter casing are treated as duplicates of each other.
What happens if I turn off both case-sensitivity and trimming?
Comparison becomes case-insensitive but still sensitive to leading/trailing whitespace differences, so "apple" and "apple " (with a trailing space) would still be treated as different lines even though "Apple" and "apple" would now match.
Does the tool remove duplicate words within a single line?
No, this tool operates on whole lines only. Each line of your input is treated as one item to compare; it does not look inside a line for repeated words.
Is my list uploaded to a server?
No, deduplication runs entirely in your browser using JavaScript as you type or change the options. Nothing is uploaded.
Can I copy the deduplicated result?
Yes, a Copy button appears above the result once there is output, copying the full deduplicated list to your clipboard.
Does line order within a duplicate group matter for which one is "first"?
Yes, "first" and "last" always refer to position in your original pasted input, top to bottom — not any alphabetical or other sorting.

Part of These Collections

Also Available As

duplicate line remover, remove duplicate lines, deduplicate list online, unique lines tool, remove duplicates from text, dedupe list

Found a Problem?

Let us know if something with Duplicate Line Remover isn't working as expected.

Thanks — we'll take a look.