Text & Developer tool

Remove Duplicate Lines Online

Paste a list, remove repeated lines and copy the unique ones.

  • Instant results
  • Working shown
  • No sign-up
  • Runs in your browser
ToolUpdates as you type
2
duplicate lines removed
  • Lines in8
  • Unique lines out5
  • Empty lines removed1

The first copy of each line is kept, in its original position.

Your text stays in your browser. Nothing is sent or saved.

How it works

This tool removes duplicate lines from a list and keeps the first copy of each line in its original order. You can ignore upper and lower case, trim spaces at the ends of lines and drop empty lines. Paste your list, and copy the unique lines from the result box.

This remove duplicate lines tool cleans a list in one step. Paste names, emails, roll numbers or keywords, one per line, and it keeps only the unique lines.

How to remove duplicate lines online

  1. Paste your list in the top box, one item per line.
  2. Choose the options you need: Ignore case, Trim spaces at the ends and Remove empty lines.
  3. Read the summary: lines in, unique lines out and repeats removed.
  4. Click Copy result.

Example

Input (8 lines):

Java
Python
java
SQL
Python

React
SQL 
Option Result Removed
Ignore case off, trim on Java, Python, java, SQL, React 2 repeats and 1 empty line
Ignore case on, trim on Java, Python, SQL, React 3 repeats and 1 empty line

The last line is "SQL " with a space at the end. Trimming makes it match the earlier "SQL".

Options explained

Option What it does When to turn it off
Ignore case Java, JAVA and java count as one line When capital letters matter, as in codes or passwords
Trim spaces at the ends Removes spaces before and after each line When leading spaces matter, as in indented code
Remove empty lines Drops blank lines When blank lines separate groups

Common mistake: A common mistake is removing duplicates from data copied out of Excel without trimming. Cells often carry trailing spaces, so "Ravi" and "Ravi " look the same but are different lines.

Unique lines in code

Removing duplicates while keeping order is a common coding question. In Python, a dictionary keeps insertion order, so this works:

lines = ['Java', 'Python', 'java', 'SQL', 'Python']
print(list(dict.fromkeys(lines)))

Output:

['Java', 'Python', 'java', 'SQL']

To ignore case, track lower-case keys in a set, as this tool does:

lines = ['Java', 'Python', 'java', 'SQL', 'Python']
seen = set()
out = []
for line in lines:
    key = line.lower()
    if key not in seen:
        seen.add(key)
        out.append(line)
print(out)

Output:

['Java', 'Python', 'SQL']

Practise the same idea on arrays with remove duplicates from an unsorted array and remove duplicates from a sorted array in place. For tables of data, see removing duplicate records.

Pro tip: On Linux, sort file.txt | uniq also removes repeated lines, but it changes the order, because uniq only joins neighbouring lines. See Linux commands for more.

Need the list in A to Z order too? Use the sort lines alphabetically tool. Your text stays in your browser and is never saved.

Frequently asked questions

How do I delete duplicate lines from a list?
Paste the list with one item per line. The result box shows each line only once, and the summary shows how many repeats were removed. Click 'Copy result'.
Does it change the order of my lines?
No. The first copy of each line stays where it was and later copies are removed. To put the list in order as well, use the sort lines alphabetically tool.
What does 'Ignore case' do?
It treats Java, JAVA and java as the same line and keeps only the first one, with its original spelling. Leave it off if case matters, for example in passwords or code.
Why are two lines that look the same not removed?
One of them probably has a space at the end, or a different invisible character. Keep 'Trim spaces at the ends' on to fix spaces at the start and end.
Is my list sent anywhere?
No. Everything runs in your browser, so you can paste email lists or roll numbers safely.

Try another tool

See all free tools
Chat with us