Independent writing tools and guides, edited by a human

Remove Duplicate Lines

Find and remove duplicate lines with case sensitivity, trim, and keep-first or keep-last control. Reports what was removed.

Your workbench
0 characters
Read-only
Ready when you are.
On this page (09)
  1. 01The duplicate that costs money
  2. 02How the deduplication works under the hood
  3. 03The three settings that matter
  4. 04When to dedupe, and when not to
  5. 05Practical examples
  6. 06Tips
  7. 07Common mistakes
  8. 08Limitations, stated plainly
  9. 09Frequently Asked Questions

The duplicate that costs money

You merged two mailing-list exports and pasted the result into your email platform, and the subscriber count came out 4,380 instead of the 4,102 you expected. Nobody's email is wrong. The same people are simply in there twice, because they signed up at a conference and later through the website footer, or because one export stored the address as "Ana.Silva@Example.com" and the other as "ana.silva@example.com." Duplicate lines are the tax you pay whenever two lists meet.

The tool above finds and removes them, reports what disappeared, and hands you the decisions that actually matter: case sensitivity, whitespace trimming, keep-first versus keep-last, and an optional sort of the result. Everything runs in your browser, so your lists never leave your device. That matters when the list is client emails, patient initials, or an unreleased guest roster.

How the deduplication works under the hood

The algorithm is deliberately simple. Your text is split into lines. Each line is optionally normalized before comparison: leading and trailing whitespace is trimmed, and if case-insensitive mode is on, letters are folded to one case for the comparison only. The tool maintains a set of normalized lines it has already seen. When a line's normalized form is already in the set, it is a duplicate, and your keep-first or keep-last setting decides which copy walks away.

Two consequences are worth understanding:

  • Normalization happens for comparison, not for output. With case-insensitive mode on, if "Ana@x.com" appears before "ana@x.com," the surviving line keeps its original spelling. The tool removes lines; it never rewrites them.
  • Only exact lines match. Two lines that differ by a single invisible character (a trailing non-breaking space, a zero-width space picked up from a web page) are not duplicates until trimming or cleaning removes the difference. Running messy lists through the text cleaner first produces more honest dedupe counts.

The three settings that matter

Case sensitivity. Email addresses and usernames are case-insensitive in practice; nearly every mail system treats Ana@x.com and ana@x.com as one mailbox, so dedupe those with case sensitivity off. Code identifiers, passwords, and some part numbers are genuinely case-sensitive. When unsure, run case-sensitive first, then case-insensitive, and compare the counts. A large gap means capitalization is doing real work in your list, and you should look at samples before choosing.

Trim first. Lists assembled by copy-paste carry trailing spaces and stray tabs. Without trimming, "apple " and "apple" count as different lines. Trim for any human-facing list; skip it only when leading whitespace carries meaning, as in indented outlines, YAML, or code.

Keep first versus keep last. This decides which copy survives when duplicates differ in more than case.

SituationKeepWhy
Old export on top, newer export pasted belowLastLater entries carry fresher information
Signup sheet where people resubmit to correct mistakesLastThe bottom entry is the intended one
Chronological log where first sighting mattersFirstYou want when something first appeared
Ranked list (keywords by priority, top-10 anything)FirstPosition is information; do not scramble it

The optional sort switch reorders the deduped result alphabetically. Use it when the list has no inherent order; leave it off when the original sequence means something, since the sort runs only on the lines that survived deduping and never changes which occurrence counts as "first."

When to dedupe, and when not to

Deduping is safe when a line's identity is all it carries: mailing lists, guest lists, tag vocabularies, brainstorm keywords from three sessions that need merging, bibliographies where a repeated citation is redundant by definition.

Deduping is destructive when the repetition is the data:

  • Survey responses. Twelve identical answers to "How did you hear about us?" is a finding, not noise.
  • Vote tallies and attendance rows. One row per person per event means identical rows record identical events.
  • Inventory and transactions. Three lines reading "Widget A" are three widgets.
  • Log files, sometimes. Repeated identical errors can signal a retry storm you need to see. Dedupe logs to discover which error types exist, never to count how often they occurred.

Practical examples

A guest list from three channels. Confirmations arrived in a spreadsheet column, an email thread, and a paper sign-up someone typed in later. Concatenate all three, trim, dedupe case-insensitively, and read the removed report by hand. Deduping shrinks the review pile; it does not replace the review, because "Sam Lee" twice might be one person or two.

Bibliography cleanup. Merging a reference-manager export with hand-typed sources produces exact repeats. Dedupe catches those. Near-duplicates (the same paper cited in two styles) survive and need a human eye; sort the list first so near-duplicates land adjacent and are easy to spot.

Tips

Sort first if you want sorted output anyway. Keep-first and keep-last behave predictably when the order entering the tool is intentional rather than accidental.

Dedupe twice, once per case setting. The difference between the two counts tells you how much capitalization variance your list carries, which is often its own data-quality finding.

Normalize the source before deduping. Invisible characters and stray spaces are why "identical" lines fail to match. One pass through a cleaner usually recovers the duplicates the deduper could not see.

Treat the removed report as a QA sample. Do not just read the count. Skim the actual removed lines for false positives before you trust the output.

Common mistakes

Expecting near-duplicate detection. The tool matches exact lines after normalization. "J. Smith, jsmith@x.com" and "John Smith, jsmith@x.com" both survive, correctly, because no line-based tool can know they are one person. For small lists, sorting by the identifier column puts near-duplicates next to each other so your eye can finish the job.

Assuming order does not matter. With a keep-first versus keep-last setting, it always matters. Decide what your list's order means before you choose.

Deduping a count. Survey rows, votes, inventory, event logs. It is the only mistake on this page that silently destroys real data, so it earns a second mention.

Limitations, stated plainly

The tool compares whole lines as text. It knows nothing about records, fields, or identity: it cannot tell that "Ana Silva" and "A. Silva" are one person, cannot merge near-duplicates, and cannot distinguish a legitimate repeat from an accidental one. That judgment is yours, before you press anything, and the tool will delete either with equal confidence. The hard limit is a character cap, not memory: each text field accepts about 200,000 characters, which is roughly ten thousand short lines, so lists of millions of rows belong in a database or a command-line utility. And deduping never fixes bad data. It makes a list of unique lines shorter, not more correct.

Frequently Asked Questions

Is deduplication the same as sorting?

No. Deduping removes repeated lines; sorting reorders them. The two tools stay separate on purpose: the text sorter only reorders the lines you give it, while this tool offers finer control over case, trim, and which occurrence survives.

Should I keep the first or the last occurrence?

Keep last when later entries are corrections or updates, such as a re-submitted signup or a newer export pasted below an older one. Keep first when position carries meaning, like a ranked list or a chronological log. If duplicates are byte-identical, the setting makes no difference; it only matters when the copies vary.

Does it catch duplicates that differ only in capitalization?

Yes, with case sensitivity turned off. "Bob@X.com" and "bob@x.com" then count as one line, and the survivor keeps whichever spelling it originally had. For email lists, case-insensitive is almost always the right choice.

Can I undo a dedupe?

Not inside the tool, which is exactly why it reports what it removed. Keep the original in a scratch file or on the clipboard until you have checked the report. Restoring means pasting the original back and starting over.

Will it remove duplicate words inside a line?

No. The tool works line by line, so two identical lines collapse into one, but a sentence reading "the the cat" is untouched. Word-level repetition in prose is an editing problem; our guide to cutting filler words covers the patterns worth hunting by hand.