Line Tools

Sort, dedupe, shuffle, number and count lines of text.

Runs in your browser Instant No sign-up
Lines
Result

Paste, type or drop a file — output appears as you type.

Waiting for input
Processed locally · nothing is uploadedProcessed locally

Operations

Pick an operation and the result updates as you type. The status bar shows the line count before and after, e.g. 6 lines → 3 unique lines.

Operation What it does
Sort A → Z / Z → A Character-code order, stable (equal lines keep their order).
Sort numerically By the leading number of each line; lines without one go last.
Natural sort Numbers inside text compared by value: file2 before file10.
Remove duplicates Keeps the first occurrence of each line.
Reverse order Last line first.
Shuffle Random order from the Web Crypto random generator.
Trim whitespace Removes leading and trailing spaces and tabs from every line.
Remove empty lines Drops lines that are empty or contain only whitespace.
Number lines Prefixes 1. , 2. … with the numbers right-aligned.
Count occurrences One line per distinct value as count line, most frequent first.

Ignore case and Trim before comparing appear for the operations that compare lines: Sort A → Z, Sort Z → A, Natural sort, Remove duplicates and Count occurrences. They change how lines are compared, not what is output.

Examples

Version tags sorted A → Z and with natural sort:

v1.10.0          v1.2.0
v1.2.0           v1.2.10
v1.2.10          v1.9.3
v1.9.3           v1.10.0
v2.0.0           v2.0.0

The left column is A → Z: 1 is smaller than 2 and 9 as a character, so v1.10.0 comes first. Natural sort (right) puts the versions in release order.

Counting IP addresses copied from an access log:

203.0.113.7
198.51.100.23
203.0.113.7
192.0.2.44
203.0.113.7
198.51.100.23

gives

3  203.0.113.7
2  198.51.100.23
1  192.0.2.44

Lines with the same count keep the order in which they first appeared.

Sorting 10 apples, 9 pears, 100 plums, n/a, -3 debt numerically gives -3 debt, 9 pears, 10 apples, 100 plums, n/a; A → Z would give -3 debt, 10 apples, 100 plums, 9 pears, n/a.

Common surprises

  • Capitalised words sort first in A → Z. Apple comes before apple and before banana, because uppercase letters have lower character codes. Turn on Ignore case, or use Natural sort.
  • Duplicates that look identical are not removed. Usually one line has a trailing space or tab. Turn on Trim before comparing, or run Trim whitespace first.
  • Accented letters with A → Z. Character-code order puts é after z. Natural sort uses Unicode collation, which puts é next to e.

Shell equivalents

LC_ALL=C sort file.txt          # Sort A → Z
sort -f file.txt                # … with Ignore case
sort -n file.txt                # Sort numerically (non-numbers are treated as 0 here, not moved last)
sort -V file.txt                # natural ("version") sort, GNU coreutils
awk '!seen[$0]++' file.txt      # Remove duplicates, keeping the first
tac file.txt                    # Reverse order
shuf file.txt                   # Shuffle
sort file.txt | uniq -c | sort -rn   # Count occurrences

For other text clean-up, see the Case Converter and Word Counter. To compare two lists after sorting them, use Text Diff; for spreadsheet data, open it in the CSV Viewer.

Frequently asked questions

What is the difference between Sort A → Z and Natural sort?

Sort A → Z compares lines character by character by character code, like LC_ALL=C sort or JavaScript's default sort: uppercase letters come before lowercase ones and "10" comes before "9". Natural sort compares runs of digits by their numeric value and letters alphabetically, so file2 comes before file10 and v1.9 before v1.10. Use A → Z for exact, reproducible ordering and natural sort for lists people read.

How does Sort numerically handle lines that are not numbers?

It reads the number at the start of each line (after any spaces), including signs, decimals and exponents such as -2.5, .5 and 1e3. Lines that do not start with a number are moved to the end and keep their original order.

Which duplicate is kept by Remove duplicates?

The first one, in its original position; later copies are dropped. With Ignore case on, Admin and admin count as the same line, and with Trim before comparing on, leading and trailing spaces are ignored too. The kept line is output exactly as it was written.

Is Shuffle really random?

Yes. It is a Fisher–Yates shuffle driven by crypto.getRandomValues, the browser's cryptographically secure random generator, with rejection sampling so every order is equally likely. It is not seeded, so each run gives a different order.

Does it keep Windows line endings?

Yes. If the input uses CRLF, the output does too, and no stray carriage return is left at the end of a line, so sorting a file copied from Windows does not produce invisible differences. A trailing newline at the end of the input is kept.

Is my text uploaded?

No. Everything runs in your browser and nothing is uploaded.

Last updated