# Line cleaner

> Remove duplicate lines, sort A-Z, Z-A, by length or by number, trim spaces and drop empty lines, with before and after counts. Free, in your browser.

Canonical: https://toolspace.tech/line-cleaner/
Last updated: 2026-10-25

Remove duplicate lines, trim spaces, drop blank lines and sort a list A–Z, Z–A, naturally, by length or by number, with before and after counts. Runs in your browser.

This is an interactive tool that runs in the browser: [open the Line cleaner](https://toolspace.tech/line-cleaner/) to use it. Nothing typed into it is uploaded.

## Worked example

Duplicates removed ignoring case, spaces trimmed, the blank line dropped, then sorted A–Z. Apple and pear keep the casing of their first appearance.

**lines**

```
pear
Apple
  banana
apple

Pear
```

**cleaned**

```
Apple
banana
pear
```

## Common mistakes

### Spaces hiding duplicates

"apple" and "apple " look the same but aren’t. Keep Trim spaces on unless the spaces matter.

### Sorting numbers as text

A–Z puts 10 before 9. Use natural sort or sort by number for lists of IDs, versions or amounts.

### Forgetting about case

By default, Apple and apple are different lines. Turn on Ignore case for emails, tags or keywords where case doesn’t matter.

### Sorting when order matters

Keep order removes duplicates without moving anything, which is what you want for steps, logs or ranked lists.

## How it works

1. **Paste your lines:** One item per line: emails, IDs, keywords, log lines. Open a text file or drop it on the left; it’s read on your machine and never uploaded.
2. **Choose what to clean:** Remove duplicates (optionally ignoring case), trim spaces from each line, drop blank lines, then pick a sort order or shuffle. Reverse flips whatever order you end up with.
3. **Check the counts and copy:** The counts show how many lines you had, how many were unique, and how many duplicates and blank lines were removed. Copy the result or download it as a .txt file.

## Questions

### Which copy of a duplicate is kept?

The first one, in its original position. With Ignore case on, Apple and apple count as the same line, and whichever comes first keeps its casing.

### What’s the difference between A–Z and natural sort?

A–Z compares text character by character, so item10 comes before item2. Natural sort reads runs of digits as numbers, so item2 comes before item10. Both follow your browser’s language rules for accents and case.

### How does sorting by number work?

Each line is sorted by the first number in it, such as 42, -3 or 2.5. Lines without a number go to the end, in their original order. A dash right after a letter, as in item-7, isn’t read as a minus sign.

### Does it handle Windows line endings?

Yes. Lines can end in \n, \r\n or \r, and the result uses \n. One line break at the very end doesn’t count as an extra empty line.

### Is my text uploaded?

No. Everything happens in this tab.

## Related

- [List to SQL IN](https://toolspace.tech/list-to-sql-in/)
- [Word counter](https://toolspace.tech/word-counter/)
- [Case converter](https://toolspace.tech/case-converter/)
- [Diff checker](https://toolspace.tech/diff-checker/)
