Line Tools
Remove duplicate or empty lines, sort, trim and tidy text line by line
Loading the tool…
Tidies a list with one item per line: removes duplicate and empty lines, sorts alphabetically, trims spaces and more. Use it to clean up a list of names or keywords copied from a spreadsheet.
How to use
- Paste your list into "Input".
- Press step buttons such as "Remove duplicates", "Remove empty lines" or "Sort". Each step is applied to the "Result" in the order you press them.
- If you pressed the wrong one, "Undo" removes the last step and "Undo all steps" returns to the original text.
- Press "Copy" or "Download" to take the result.
How it works
- "Remove duplicates" compares lines without leading and trailing spaces, keeps the first occurrence and keeps the original order. "Show how many times each occurs" puts the count in front of each line.
- "Sort" offers "A to Z", "Z to A", "Natural (2 before 10)", shortest or longest first, and "Random". Upper and lower case are treated alike.
- With "Regular expression" on, "Find and replace" and the matching-line steps use regular expressions. In a separator, write a line break as \n and a tab as \t.
- Your input is saved in this browser.
Questions and answers
- Can I remove duplicate lines without changing the order?
- Yes. "Remove duplicates" does not sort; it keeps the first occurrence. "apple, banana, apple" becomes "apple, banana".
- Why does item10 come before item2 when I sort?
- A normal sort compares character by character, and 1 comes before 2. Choose "Natural (2 before 10)" under "Sort order" to get item2 before item10.
- How do I join lines into one line separated by commas?
- Enter ", " as the "Separator" and press "Join into one line"; all non-empty lines are joined with commas. "Split at separator" does the opposite.
- Can I keep only the lines that contain a word?
- Enter the word under "Find" and press "Keep matching lines". To delete those lines instead, press "Remove matching lines".