Remove Duplicate Lines

Delete duplicate lines from any list or text, with trim, case and sort options — instantly in your browser.

Runs in your browserUpdated Built and maintained by Leon and Henrik

Paste a list and strip out duplicate lines instantly, with trim, case and sort options. Free. No sign-up. Runs in your browser, nothing is uploaded.

Remove Duplicate Lines
0
Lines in
0
Lines out
0
Removed
Runs in your browser
Nothing is uploaded

Paste a list, get every line exactly once. The tool keeps the first occurrence of each line, preserves your original order and shows how many lines went in, came out and were removed, so you can see at a glance whether the clean-up did what you expected.

It is the quickest way to merge two keyword exports, tidy an email list before an import or count the distinct values in a column without writing a formula.

The four switches and what they change

  • Trim each line (on by default) strips spaces and tabs at the start and end of each line before comparing, and the kept lines come out trimmed too. Without it, apple and apple (with a trailing space) are two different lines. Spaces inside a line are never touched.
  • Case-insensitive match treats Apple, apple and APPLE as one line and keeps whichever spelling appears first. Leave it off for anything where capitalisation carries meaning: API keys, hashes, case-sensitive product codes.
  • Remove empty lines drops blank rows completely. With it off, blank lines are deduplicated like any other line, so the first blank stays and every later one goes.
  • Sort A → Z alphabetises the unique lines after duplicates have been removed. It is a natural-language sort, not a computer-style code-point sort, which matters for the edge cases further down.

Worked example: one list, four results

Take this seven-line paste, where the third line has a trailing space and the fifth line is empty:

apple
Banana
apple 
APPLE

banana
cherry
Options switched onLines outRemovedWhat you get
None (trim off)70Nothing matches exactly; apple still has its space
Trim (the default)61apple collapses into apple
Trim + case-insensitive43apple, Banana, the blank line, cherry
Trim + case-insensitive + remove empty34apple, Banana, cherry

The jump from 6 to 4 is the whole story of case folding: APPLE and banana vanish because earlier lines already "own" those words. If those spellings matter to you, that is your cue to leave the option off.

Edge cases that surprise people

  • The trailing newline. If your paste ends with a line break, "Lines in" counts an extra empty line. It is not a bug, it is how text works; tick Remove empty lines if you do not want it.
  • Numbers sort as text. With sorting on, item10 comes before item2, because the comparison goes character by character and 1 is smaller than 2. Pad numbers with zeros (item02) or use the 0 → 9 order in the text sorter if you need numeric order.
  • Sorting is human-friendly. Lowercase and uppercase versions of the same word end up next to each other (apple, Apple, banana) rather than all capitals first, as you would get from a plain byte sort.
  • Near-duplicates survive. https://example.com and https://example.com/, Müller and Mueller, two spaces versus one in the middle of a line: all different. Normalise those before you paste.
  • Whole CSV rows are compared as a unit. Two rows that differ only in a timestamp column are not duplicates. Paste just the column you care about.

Doing the same thing elsewhere

Sometimes you want the result inside another workflow. The equivalents, and how they differ from this tool:

MethodKeeps original order?Notes
This toolYes (unless you sort)Live preview, counts in/out, optional trim and case folding
sort -u file.txt (Unix shell)No, output is sortedFast for huge files; ordering depends on your locale
awk '!seen[$0]++' file.txtYesThe classic "keep first occurrence" one-liner; no trimming
Spreadsheet "remove duplicates" featureYesWorks on selected columns or whole rows; changes the sheet in place

For a one-off list of a few thousand lines, pasting here is quicker than opening a terminal. For a multi-gigabyte log, use the shell.

Checking what was removed

The "Removed" counter is a sanity check. If it is far higher than you expected, an option is probably merging lines you meant to keep, case folding being the usual culprit. Run the original and the cleaned list through the text diff to see exactly which lines went, and use the word & character counter if you need totals beyond line counts.

Frequently asked questions