Line Tools
Line sorter and text tools online. Sort lines, remove duplicates, trim whitespace, reverse order. Manipulate text lines free in your browser.
Text (one item per line)
Features
- Sort lines alphabetically or reverse
- Remove duplicate lines while preserving order
- Trim whitespace from each line
- Remove empty lines
- Reverse line order
- Number lines automatically
Common Use Cases
- Sort import statements in code
- Organize list of names or items
- Clean up messy text files
- Remove duplicate entries from lists
- Prepare data for CSV import
Text Line Manipulation Techniques
Line-based text processing treats each line as an independent unit that can be sorted, filtered, or transformed. This is fundamental to Unix text processing and very useful for data cleanup.
Common operations:
- Sorting - Alphabetical (A-Z), reverse (Z-A), or natural (numbers sorted correctly)
- Deduplication - Remove exact duplicate lines, keep first or last occurrence
- Trimming - Remove leading/trailing whitespace from each line
- Filtering - Remove empty lines or lines matching a pattern
Use cases: Sorting imports in code files, organizing to-do lists, cleaning CSV data, removing duplicate entries from logs, preparing lists for alphabetical index.
Examples
Input:
import React
import axios
import lodash
→ Sorted alphabeticallyInput:
apple
banana
apple
cherry
→ Output: apple, banana, cherryInput:
hello
world
→ Output: hello, world (trimmed)Frequently Asked Questions
Normal sort treats numbers as strings, so "10" comes before "2". Natural sort recognizes numbers, so "2" comes before "10". Use natural sort for lists with numbers.
Yes! The tool keeps the first occurrence of each unique line in its original position, removing only the subsequent duplicates.
Yes! Case-insensitive sort treats "Apple" and "apple" as the same for sorting purposes, but preserves the original case in the output.
Empty lines are typically moved to the beginning or end of the sorted list. You can also choose to remove them entirely before sorting.
Yes! The line numbering feature adds sequential numbers to the beginning of each line, useful for creating numbered lists or referencing specific lines.
💡 Tips
- Before sorting code imports, make sure they're one per line—use Find & Replace to convert comma-separated imports
- Use "Remove empty lines" + "Trim whitespace" together to clean up messy copy-pasted text
- Natural sort is essential for filenames with numbers like "file1, file2, file10" to sort correctly
- When preparing CSV data, remove duplicates first, then sort to make it easier to spot remaining issues