← Text

Line Tools

Sort, deduplicate, shuffle, reverse, trim, number, prefix, join, and split lines of text in place, with undo.

Actions

Sort

Clean

Prefix and suffix

Join and split

History

Nothing to undo yet.

Your lines

Lines
0
Non-empty
0
Unique
0
Duplicates
0
Words
0
Characters
0
Longest line
0

About this tool

Line Tools is a workbench for text that comes one item per line: lists of names, file names, URLs, email addresses, CSV columns, log entries, or to-do items. Paste the text once, then apply actions in place: sort A to Z, Z to A, in natural order so file2 comes before file10, or by length; shuffle or reverse; remove duplicate or blank lines; trim leading and trailing spaces; add or strip line numbers; put a prefix or suffix on every line; join all lines with a separator or split a delimited string back into lines. Every action can be undone, up to twenty steps back, and live statistics show the line, word, character, and unique-line counts as you work. It suits anyone who would otherwise reach for a spreadsheet or a text editor macro to tidy a list.

How it works

The text is split on line breaks (CRLF and LF are both accepted) and each action is a pure function from one list of lines to another. Alphabetical sorts use the browser's Intl.Collator for the English locale, which orders letters the way a dictionary does rather than by raw character code, so uppercase and lowercase letters interleave. Natural sort turns on the collator's numeric option, comparing runs of digits by value so 2 sorts before 10. Length sorts are stable: lines of equal length keep their original order. Shuffle is an unbiased Fisher–Yates shuffle driven by the browser's cryptographic random source. Remove duplicates keeps the first occurrence of each line, optionally comparing case-insensitively. Remove line numbers strips a leading number followed by a period, parenthesis, colon, or dash, and only strips bare numbers followed by a space when every line has one, so a line that merely starts with a year is left alone. Join and split accept \n and \t as escape sequences in the separator. Before each action the previous text is pushed onto a 20-entry undo stack.

Frequently asked questions

What is the difference between A to Z and natural sort?

A to Z compares text character by character using dictionary order, so file10 comes before file2 because the character 1 sorts before 2. Natural sort recognizes runs of digits and compares them as whole numbers, giving file1, file2, file10. Use natural sort for file names, version numbers, chapter titles, and anything else with embedded numbers.

Does remove duplicates keep the first or the last copy?

The first. Each line is compared with the lines already seen, and later repeats are dropped, so the original order of the surviving lines is preserved. With Ignore case checked, Apple and apple count as the same line and the first spelling encountered is kept. Trailing spaces are not ignored; run Trim lines first if the list is untidy.

How does undo work, and is there a limit?

Every button that changes the text first saves the current text to an undo stack that holds the last twenty states. Undo restores the most recent one and Redo reapplies it. Typing directly in the box is handled by the browser's own undo (Ctrl+Z inside the text area), while the Undo button covers the tool's actions. Reloading the page clears the history.

Can I join lines into a comma-separated list and back?

Yes. Type the separator in the Join/Split box, for example a comma followed by a space, then press Join to collapse all lines into one. Split does the reverse, breaking the text at every occurrence of the separator. Use \n for a newline or \t for a tab in the separator field, which lets you turn a tab-separated line into a list or vice versa.

Related tools

Word Counter · Case Converter · Text Diff · Lorem Ipsum Generator · Slug Generator · Find and Replace · Markdown Preview · Text Cleaner

Browse all Text Tools, or go back to every free tool on HeroYears.