Line tools: trim, dedupe, sort
In one pass: trim lines, remove empty or duplicate lines, count repeats, filter by length, sort (including natural and pinyin order) and add a prefix or suffix.
Process locally
Files stay in this browser session. Closing or clearing releases them.
Add text
Type or paste the text to process
Adjust settings
Optional: Trim spaces, Remove empty lines, Duplicates and more
Run
Processes in this browser; cancel at any time
About this tool
Clean up a list with one item per line: remove duplicate lines, delete empty lines, sort, and add text to the start or end of every line. It suits keyword lists, email lists, log lines, file names or a column copied from a spreadsheet.
All settings are applied in one run. Lines can be sorted by code point, in natural order where item2 comes before item10 and Chinese sorts by pinyin, by length, by how often they occur, in reverse or at random, and each line can show its count. Up to 1 MB of text is processed in your browser and is not uploaded.
How to use it
- Paste your list with one item per line, or select Use example.
- Choose how to “Trim spaces”, whether to “Remove empty lines”, and what to do with “Duplicates”.
- Pick a “Sort” order, and fill in “Minimum length”, “Maximum length”, “Prefix” or “Suffix” if you need them.
- Select Run, then preview lines.txt and download it.
Formats and limits
- Input
- Text
- Output
- Plain text
- Size limit
- 1 MB
- Settings
- Trim spaces (Both ends, Start, End, Keep); Remove empty lines; Duplicates (Keep, Remove, Remove, ignoring case); Show how often each line occurs; Sort (Keep order, A to Z, Z to A, Natural, By length, Most frequent first, Reverse, Shuffle); Minimum length; Maximum length; Prefix
- Privacy
- Files stay in the current browser session. No file bytes are uploaded.
- Price
- Free, no sign-up
Common questions
How do I count how many times each line appears?
Set “Duplicates” to “Remove”, tick “Show how often each line occurs” and choose “Most frequent first” under “Sort”. Each line then starts with its count and a tab, so it pastes into a spreadsheet as two columns.
Which copy is kept when duplicates are removed?
The first one, in its original position. With “Remove, ignoring case”, Apple and apple count as the same line and the first spelling is kept. Lines that differ only in spaces at the ends match only when trimming is on.
What is the difference between code point and natural order?
“A to Z (code point)” compares characters by their Unicode values, so capitals come before lowercase letters, item10 before item2, and Chinese is not in pinyin order. “Natural (numbers by value, Chinese by pinyin)” compares numbers by value, sorts Chinese by pinyin and ignores case.
In what order are the settings applied?
Trimming comes first, then removing empty lines, the length filter, removing duplicates and sorting, and finally the prefix and suffix. So the prefix and suffix do not count toward the length or the sort order, and counts include only lines that passed the filters.
How is line length counted?
In characters after trimming, so a Chinese character counts as one, not as several bytes. Both limits include the boundary value, and 0 means no limit.
Related tools
Reverse text
Reverse the characters of text or of each line, the order of lines or words, or the items of a list or JSON array; emoji stay whole.
Split and join text
Split text at a delimiter into lines, or join lines with a delimiter, optionally quoting each item for SQL or CSV.
Wrap lines to a fixed length
Break every line into pieces of at most a set number of characters or display columns, optionally only between words.
Text beautifier
Add a space between Chinese and English or numbers, optionally switch to Chinese punctuation and tidy paragraphs and spaces.
Letter case and naming styles
Change letter case line by line, or turn phrases and identifiers into camelCase, PascalCase, snake_case, kebab-case or CONSTANT_CASE.
Compare text
Compare two texts line by line with line numbers, and download a unified diff and a JSON report.