Text Line Tools

Eighteen line operations in one place: sort, deduplicate, count, number, shuffle, trim, wrap and find-and-replace — with regex support and live counters.

Code editor showing many lines of structured text

Photo by Chris Ried on Unsplash

Line manipulation tool

Operations

0Input lines
0Output lines
0Removed
0Output chars

Updated: 2 August 2026Read: 6 minMethod: In-browser string processingRuns: 100% in your browser

Key takeaways

  • Deduplication keeps the first occurrence and preserves order, which is what you usually want from an exported list.
  • Natural sort reads embedded numbers numerically, so item2 sorts before item10.
  • Sorting both sides before diffing turns an unreadable comparison into a clean one.

The eighteen operations

OperationWhat it does
Sort A→Z / Z→ALocale-aware alphabetical sort, optionally case-sensitive.
Natural sortOrders embedded numbers numerically, so item2 comes before item10.
Sort by lengthShortest line first — useful for spotting truncated records.
Remove duplicatesKeeps the first occurrence of each line, preserving order.
Keep only duplicatesShows exactly which lines appeared more than once.
Count occurrencesFrequency list, most common first, tab-separated for pasting into a spreadsheet.
Reverse / ShuffleInvert the order, or randomise it with the crypto RNG.
Number linesAdds right-aligned line numbers.
Remove blank lines / TrimStrip empty lines, or leading and trailing whitespace on every line.
Add prefix/suffixWrap every line, for building SQL IN lists, CSS selectors or Markdown bullets.
Find & replaceLiteral text, or a full regular expression when written as /pattern/flags.
Join / SplitCollapse lines into a comma-separated string, or explode one back into lines.
lowercase / UPPERCASEBulk case changes; for camelCase and friends use the case converter.

Everyday recipes

Build a SQL IN list

Paste one ID per line, choose Add prefix/suffix with prefix ' and suffix ',, then Join with commas. Wrap the result in parentheses.

Clean an exported email list

Run Trim each line, then Remove blank lines, then Remove duplicates with case-sensitivity off — addresses are case-insensitive in the domain part and effectively so in practice. Extract addresses from messy text first with the email extractor.

Diff two lists

Paste list A, run Sort, copy the result. Repeat for list B. Then compare the two sorted outputs in the text diff tool — sorting first turns an unreadable diff into a clean one.

Find repeated log messages

Paste log lines and run Count occurrences. This is the browser equivalent of sort | uniq -c | sort -rn.

Using regular expressions in find & replace

Wrap the pattern in slashes to switch from literal matching to regex: /^\s+/ strips leading whitespace, /\d{4}-\d{2}-\d{2}/ matches ISO dates. Flags go after the closing slash, and g is added automatically.

Capture groups work in the replacement field with $1, $2 and so on. To convert Lastname, Firstname into Firstname Lastname, use /(\w+), (\w+)/ and replace with $2 $1.

Build and debug patterns interactively in the regex tester, and keep the regex cheat sheet open alongside.

Working with large files

Everything runs in your browser tab on the main thread, which comfortably handles lists into the low hundreds of thousands of lines. Beyond roughly 500,000 lines the browser will feel sluggish, and beyond a few million you should reach for command-line tools:

sort file.txt | uniq            # sort and dedupe
sort file.txt | uniq -c | sort -rn  # frequency count
awk '!seen[$0]++' file.txt       # dedupe without sorting
sed 's/old/new/g' file.txt       # find and replace

The advantage of doing it here is that nothing leaves your machine — useful when the list contains customer data you should not be pasting into an unknown web service.

Frequently Asked Questions

How do I remove duplicate lines?

Paste your text and click Remove duplicates. The first occurrence of each line is kept and the original order is preserved. Turn off case-sensitivity to treat Apple and apple as the same.

What is natural sort?

A sort that reads embedded numbers as numbers, so item2 comes before item10. A plain alphabetical sort compares character by character and puts item10 first.

Can I use regular expressions in find and replace?

Yes. Write the pattern as /pattern/flags and it is treated as a regex; anything else is matched literally. Capture groups are available as $1, $2 in the replacement.

Does the tool change my original text?

No. The input box is never modified — results appear in the second box. Use Result → input to chain operations deliberately.

How many lines can it handle?

Hundreds of thousands comfortably. Past about half a million lines the browser slows down; use sort, uniq and awk on the command line for files that large.

Is my data uploaded anywhere?

No. All processing happens in JavaScript in your browser, which is why this is safe for internal lists and customer data.

Sources & further reading

  1. MDN: String.localeCompare — the locale and numeric collation used by the sort operations
  2. POSIX: uniq — the command-line equivalent of the dedupe and count operations
  3. MDN: Regular expressions — syntax reference for the find and replace field