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
- Paste your list in the top box, one item per line.
- Choose the options you need: Ignore case, Trim spaces at the ends and Remove empty lines.
- Read the summary: lines in, unique lines out and repeats removed.
- 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 | uniqalso removes repeated lines, but it changes the order, becauseuniqonly 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.
