Just File Tools

Line Tools

Sort, dedupe, reverse, shuffle, or trim lines of text

9 total8 non-empty7 unique
Sort
Transform

How to Line Tools Online

Sort, dedupe, reverse, shuffle, trim, or remove blank lines from a text block.

  1. Paste your text into the textarea — one item per line.
  2. Pick a sort mode and click Sort. Use 'natural' for content with numbers (`item1`, `item2`, `item10`); use 'alphabetical' for plain strings; use 'by length' to find the shortest or longest entries.
  3. Toggle 'Case sensitive' to control whether `Apple` and `apple` sort together or apart.
  4. Click any Transform button to apply that operation: Remove duplicates, Reverse order, Shuffle, Trim each line, or Remove blank lines.
  5. Operations chain — each click rewrites the textarea, so you can sort then dedupe then trim in three clicks.
  6. Watch the stats below the textarea: total lines, non-empty count, unique count. Click Copy to put the current content on your clipboard.

About Line Tools

Line-oriented text manipulation is the second-most-used class of tool in any developer's toolbox after find-and-replace. Every Unix-derived operating system bundles `sort`, `uniq`, `shuf`, and a handful of other line tools precisely because the operations come up constantly: deduplicating a list of email addresses, sorting test results, alphabetizing imports, randomly shuffling a training/validation split, finding the longest lines in a log file. This tool collects the six most common operations into one page with a single textarea — paste your input, click an operation, see the result, click another operation, see the result, copy when you are done.

A few of the operations have subtle behavior worth knowing.

**Natural sort** is the version of alphabetical sort that handles numeric runs correctly. Plain alphabetical sort treats characters one at a time, so it produces `item1, item10, item2` (because the character "1" is less than "2" and both are part of `item10`). Natural sort parses out the number portion, compares it as a number, and produces the human-expected `item1, item2, item10`. This is what Windows Explorer, macOS Finder, and `ls -v` on Linux do. Whenever your input has version strings, numbered identifiers, or any embedded number, you almost always want natural sort. The implementation uses `Intl.Collator` with the `numeric: true` option, which is the browser's built-in support for natural ordering and gives correct results for locale-specific numerals as well.

**Length-sort** is the tool you reach for when you want to find the shortest or longest entries in a list. Sorting log lines by length puts the most verbose entries at the bottom (length-descending) where they are easy to spot. Sorting filename lists by length surfaces unusually-long filenames that may have been generated programmatically rather than typed.

**Deduplication** preserves the first occurrence of each line by default. This matches how `uniq` works on a sorted input and how Python's `dict.fromkeys()` trick is typically used. Whitespace is significant — `apple` and `apple ` (trailing space) survive dedup as separate lines. To collapse those, run **Trim each line** first to normalize, then run dedup; the operations chain cleanly. Case-insensitive dedup is one toggle away.

**Shuffle** uses `crypto.getRandomValues` for randomness rather than `Math.random()`. This matters surprisingly often. `Math.random()` is fine for animations and game-feel jitter but is not uniformly distributed across all seeds and is predictable enough that you should not use it for anything where the unpredictability matters — A/B test assignment, dealing cards, picking a winner from a list of participants. The implementation is Fisher–Yates with rejection sampling to avoid modulo bias, the same algorithm the Password Generator uses for its character shuffle.

**Trim each line** and **Remove blank lines** are different operations. Trim removes leading and trailing whitespace from each line but keeps the line itself; Remove blank lines deletes any line that is entirely whitespace. Run them together (trim first, then remove blank) to collapse all whitespace-only content in one pass.

The **stats bar** below the textarea reports three numbers: total lines, non-empty lines, and unique lines. The gap between total and unique tells you how much duplication is in the input. The gap between total and non-empty tells you how many blank lines exist. These are recomputed live as you edit so you can watch them shrink (or grow) as you apply operations.

Everything is a small pure function with vitest coverage. No external dependencies — every operation is a few lines of JavaScript. The page makes zero network requests. Sensitive lists, internal data, anything you would not paste into a third-party site is safe to paste here.

Frequently Asked Questions

What is 'natural sort' and why would I want it?

Natural sort treats numeric runs inside strings as numbers, not characters. Alphabetical sort orders `item1, item10, item2` because `'1' < '1' < '2'` lexicographically. Natural sort orders `item1, item2, item10` because it parses out the number portion and compares numerically. This is what filename sorting in Windows Explorer and macOS Finder does, what `ls -v` does on Linux, and what most humans expect for any input containing numbers. Use it whenever your lines have version numbers, sequence numbers, or numbered identifiers.

Does 'Remove duplicates' care about whitespace?

Yes. `apple` and `apple ` (trailing space) are different lines and both survive deduplication. To collapse these together, run 'Trim each line' first to normalize whitespace, then 'Remove duplicates'. The order matters: trim normalizes the input, then dedupe sees only the trimmed values.

What random source does Shuffle use?

`crypto.getRandomValues` — the same cryptographically-secure source the Password Generator tool uses. The shuffle is a Fisher–Yates algorithm with rejection sampling to avoid modulo bias. Practical effect: the result is genuinely uniformly random, suitable for things like dealing a deck of cards, picking lottery winners, or generating a random training-set split.

Why are the operations in-place rather than producing a separate output?

Because line operations chain. You almost never want to sort, then dedupe a *copy* — you want to sort and then dedupe the sorted result. The single-textarea design makes chaining one-click: click Sort, click Remove duplicates, click Trim each line. Each click rewrites the textarea. If you need the original back, use undo (Ctrl/Cmd+Z) — the textarea preserves history.

How do empty lines get sorted?

Empty lines sort to the top in ascending order, the bottom in descending order, the start in length-ascending (length 0 is shortest), the end in length-descending. If you do not want empty lines in your output at all, click 'Remove blank lines' before sorting. The two operations compose cleanly.

What is the difference between 'Trim each line' and 'Remove blank lines'?

Trim removes leading and trailing whitespace from each line but keeps the line itself, even if the line becomes empty. Remove blank lines deletes lines that consist of only whitespace (including the line break). Run trim first, then remove blank lines, to collapse all whitespace-only content.

Is the data sent to a server?

No. Every operation is a pure function on the current textarea content, running in your browser. No network requests, no logging. Sensitive content (internal lists, email addresses, secrets you want to deduplicate) stays local.