Writing & Text

Text Manipulation Tool

Reverse, sort, dedupe, trim, shuffle. Ten common line-based text operations in one place.

8 lines · 8 words · 52 characters

Common text-cleaning tasks

List manipulation comes up daily for anyone working with data, content, or scripts. Most operations have command-line equivalents (sort, uniq, head, tac, awk) but this tool covers the highest-frequency ones in the browser without context-switching.

Operations explained

Reverse text

Reverses every character. “Hello” → “olleH”. Includes whitespace and punctuation. For palindrome checking, comparing reversed text to original works.

Reverse line order

Last line becomes first, etc. Each line stays intact. Equivalent to tac on Linux.

Sort A→Z / Z→A

Alphabetical sort using locale-aware comparison. Numbers sort lexically (“10” before “2”); for natural numeric sort, prefix numbers with leading zeros first. Equivalent to sort / sort -r.

Sort by length

Shortest line first. Useful for spot-checking long outliers or when working with words/codes of varying length.

Remove duplicates

Keeps first occurrence, drops repeats. Preserves original order otherwise. For sorted-and-deduplicated, run sort then dedupe (or use sort + uniq on Linux).

Trim whitespace

Strips leading and trailing spaces/tabs from each line. Doesn't collapse internal whitespace. Useful for cleaning up data exports where each line has trailing spaces.

Remove blank lines

Drops any line that's empty or only whitespace. Compresses spacing in messy text.

Add line numbers

Prefixes each line with its 1-based number. Useful for emails, code reviews, references.

Shuffle

Random reordering using Fisher-Yates (uniform). Each click of “Re-shuffle” gives a fresh random order. Uses Math.random() — fine for casual use, not crypto-secure.

Common workflows

  • Clean a copy-pasted email list: trim whitespace, remove blank lines, sort, remove duplicates.
  • Pick a random winner from entries: paste names, shuffle, take the first line.
  • Check if a word is in a list: paste list, sort A→Z, scan visually.
  • Generate sequential references: paste content, add line numbers.
  • Find length outliers: sort by length, look at the extremes.

Programmatic alternatives

For scripts and large files, command-line tools are usually faster:

  • sort file.txt | uniq — sort and remove consecutive duplicates
  • tac file.txt — reverse line order
  • rev file.txt — reverse each line's characters
  • shuf file.txt — shuffle (random sort)
  • nl file.txt — add line numbers (or cat -n)
  • awk 'NF' file.txt — remove blank lines
  • sed 's/^[[:space:]]*//;s/[[:space:]]*$//' — trim whitespace

For other text tools: Word Counter for length and reading time, Character Counter for social-media limits, Title Case Converter for case styles.

Frequently Asked Questions

What does this tool do?
Ten common line-based text operations: reverse text, reverse line order, sort A→Z or Z→A, sort by length, remove duplicate lines, trim whitespace, remove blank lines, add line numbers, and shuffle. Useful for cleaning lists, prepping data, or just one-off text transformations.
How does "remove duplicates" work?
Keeps the first occurrence of each line and drops subsequent duplicates. Order is preserved. Comparison is exact (case-sensitive, whitespace-sensitive). To deduplicate case-insensitively, use "trim whitespace" first if needed.
Is sort case-sensitive?
Uses the browser's localeCompare, which is case-sensitive but locale-aware. "apple" comes before "Banana" in default ASCII sort but the locale-aware version handles non-ASCII characters correctly (é vs e, etc.). For pure ASCII case-insensitive sort, lowercase the text first.
What's shuffle for?
Random reordering of lines. Useful for: drawing names, randomizing test questions, sampling from a list, generating random playlists. Uses Fisher-Yates shuffle (uniform random distribution). Click "Re-shuffle" for a new random order.
Does my text leave the browser?
No. Everything runs client-side in JavaScript. Your text isn't sent anywhere. Safe for sensitive data — internal lists, customer info, anything you don't want logged on a third-party server.

Related Calculators