Skip to content

Remove Duplicate Lines

Remove Duplicate Lines

Paste any list and get a deduplicated version back, with options for case sensitivity, whitespace trimming, and preserving original order vs. sorting. Works on emails, names, URLs, log lines, code identifiers, or anything separated by newlines.

Why Deduplication Comes Up Constantly

Lists from real-world sources almost always contain duplicates. Mailing lists merged from two events. URL lists scraped across multiple pages. CSV exports run twice. The duplicates are usually invisible until you're staring at the file, and they cause downstream pain — duplicate emails get flagged as spam, duplicate URLs waste crawl budget, duplicate IDs corrupt joins. Removing them is the single most common cleanup step in a data pipeline.

The trick is that duplicate is rarely as simple as byte-identical. Alice@example.com and alice@example.com are the same email for delivery purposes but different strings. hello and hello differ by leading whitespace but represent the same line. http://example.com and http://example.com/ are equivalent URLs. The dedup options below cover the cases that come up most often.

How It Works

The input gets split on newlines into an array. Each line is then normalized according to the active options — lowercased if case-insensitive, trimmed if whitespace-insensitive — and the normalized value becomes a key in a Set. If a normalized key is already in the Set, the line is dropped; otherwise it's kept. Preserve order keeps the first occurrence of each unique line in original position; sort output returns the deduplicated set in alphabetical order (which is functionally equivalent to piping through sort | uniq on Unix).

Need to dedupe and then alphabetize? Toggle both options, or pipe through the sort lines tool after. Need to dedupe a CSV column rather than a flat list? Use the CSV viewer to extract the column first, then dedupe.

Common Use Cases

Cleaning a mailing list before import — case-insensitive dedup is the standard pattern, since email addresses are case-insensitive in the local part for almost every major provider. Removing redundant entries from a sitemap or a list of canonical URLs. Deduping a list of git commit messages to find the unique work that happened across branches. Cleaning a vocabulary list, glossary, or tag set. Removing repeated log lines so you can read the unique error patterns instead of the same stack trace repeating.

Worked example: what each option does

The options interact, so here is one input run through them. These nine lines (· marks a space) were pasted into the tool in Chromium on October 12, 2026, switching on one option at a time:

banana
Apple
··apple
apple
banana·
cherry

Banana
apple
SettingResult, in orderLines
Defaults (Trim whitespace on)banana · Apple · apple · cherry · (blank) · Banana6
+ Case-insensitivebanana · Apple · cherry · (blank)4
+ Remove empty linesbanana · Apple · cherry3
+ Sort alphabeticallyApple · banana · cherry3
awk '!seen[$0]++'all but the last apple (8 lines; spaces count)8
sort -u8 lines, original order lost8

What the example shows. The first occurrence always wins and keeps its position, so with case-insensitive matching you get Apple, not apple, because it came first. Trim whitespace changes what is written as well as what is compared: ··apple comes out as apple, and banana· merges into banana. Turn Trim off if leading spaces matter, for example in indented code or YAML. Blank lines are deduplicated like any other line, so one survives unless you remove empty lines. Sorting happens after deduplication and uses your browser's dictionary order, so capitals and lower case sit together (apple, Banana, cherry) instead of all capitals first as in a plain byte sort.

For comparison, the usual command-line answers treat whitespace and case literally: awk '!seen[$0]++' keeps order but leaves 8 lines here, and sort -u also leaves 8 and reorders them. The counters under the boxes count lines the way wc -l does: a newline at the very end of the text does not add an extra empty line.

Frequently Asked Questions

Does this tool upload my text?+
No. All processing happens in your browser. Your text never leaves your device.
Can I remove duplicates case-insensitively?+
Yes. Toggle the case-insensitive option to treat 'Apple' and 'apple' as duplicates.
Does it preserve the original order?+
Yes by default. The first occurrence of each unique line is kept in its original position. You can optionally sort the output alphabetically.
What's the maximum text size?+
There is no hard limit, but processing slows with very large inputs (over 100,000 lines). For typical use with CSV data, email lists, or code files, there are no issues.
Can I trim whitespace too?+
Yes. Enable the trim option to remove leading and trailing spaces before comparing lines, so 'apple' and ' apple ' are treated as duplicates.
What does "case-insensitive" do?+
It treats lines that differ only in capitalization as duplicates. "Apple" and "apple" become one entry. The original capitalization of the first occurrence is preserved.
Does it work with tabs or other delimiters?+
This tool operates on full lines (separated by newlines). For splitting by tabs or commas, use our CSV Viewer or Text Diff tools.
Can I keep only the duplicates and remove unique lines instead?+
Not in this tool — it removes duplicates and keeps one of each line. For the inverse operation (keeping only lines that appear more than once), combine this with the Diff Checker or run a quick sort and group operation in a text editor. A future option may add an invert-mode toggle if usage signal warrants it.

Related Tools

Related ToolSort Lines Alphabetically →

📖 Learn More

Related Guide How to Remove Duplicate Lines from Text →

Built by Derek Giordano · Part of Ultimate Design Tools

Privacy Policy · Terms of Service