Text Cleaner
Clean up text in one place: remove duplicate lines, sort lists, trim and collapse spaces, fix line breaks from PDFs, find and replace with regular expressions, extract emails and links, and split or join lines.
How to Use
- Paste your text, drop a text file on the box or use Open file, or pick a preset to see an example.
- Switch on the cleaning steps you want. They always run in the order shown, so, for example, spaces are trimmed before duplicates are compared.
- Use Find & replace for anything specific: plain text, whole words, or a regular expression with
$1back-references. - Read the result on the right, with counts of what changed. Copy it or download it as a text file; Show Work lists every step and its effect.
Worked Example
A pasted list of seven lines: banana, Apple, apple, “ cherry ” with stray spaces, banana again, a blank line, and Date.
Trim lines removes the spaces around cherry. Remove empty lines drops the blank line, leaving 6. Remove duplicates, ignoring case, keeps the first banana and the first Apple and drops apple and the second banana, leaving 4. Sort A → Z gives Apple, banana, cherry, Date: 7 lines in, 4 out, 2 duplicates removed.
The common mistake: sorting by character code. A plain sort puts every capital before every lower-case letter, giving Apple, Date, banana, cherry, and puts “item10” before “item2”. The natural sort used here compares letters regardless of case and numbers by value.
Show Work
The Order of Steps
Pipelines of Small Tools
Cleaning text step by step is an old idea. Doug McIlroy proposed connecting programs “like garden hose” in 1964, and pipes arrived in Unix in 1973, along with small tools that each did one job: sort, uniq to drop repeated lines, tr to swap characters and sed to find and replace. A command such as sort | uniq is still how many programmers dedupe a list.
The patterns behind find and replace go back further: Ken Thompson built regular expressions into the QED and ed editors in the late 1960s, following the mathematician Stephen Kleene’s 1951 notation for describing sets of strings. This tool runs the same kinds of steps, in a fixed order, without a terminal.
About This Tool
This tool combines the everyday text clean-ups in one pipeline: trimming and collapsing spaces, removing empty and duplicate lines, rejoining lines broken by PDFs, straightening quotes, stripping HTML and unwanted characters, sorting naturally, splitting and joining, numbering, adding text around lines, extracting emails, links, numbers, hashtags and mentions, and find and replace with whole-word and regular-expression matching. Every change is counted and shown step by step.
Everything runs in your browser; nothing you paste is sent anywhere.
Related tools: Character Counter, Text Case Converter, and Regex Tester.
Frequently Asked Questions
Which duplicate is kept?
The first one. Removing duplicates keeps each line where it first appears and deletes later copies, so the order is preserved unless you also sort. Tick Ignore case to treat “Apple” and “apple” as the same line; the first spelling is kept.
How does “Fix broken lines” work?
Text copied from PDFs and emails often has a line break at the end of every printed line. This step joins a line to the next unless it ends a sentence or the next line starts a new paragraph (a blank line or a list marker), and rejoins words that were hyphenated across the break.
What is natural sorting?
Sorting that reads numbers as numbers and ignores letter case: file2 comes before file10, and “apple” sits next to “Apple”. Plain character order puts every capital letter before every lower-case one and file10 before file2.
What regular expressions can I use?
JavaScript regular expressions, the same as in most code editors: \d+ for numbers, ^ and $ for line starts and ends, (…) groups with $1 in the replacement, and so on. If the pattern is invalid, the tool says so instead of changing anything.
Is my text uploaded anywhere?
No. Every step runs in your browser, and nothing is sent or stored, so it is safe for confidential lists and documents.
How do I use the Text Cleaner?
Just type your numbers. The answer shows up right away — there is no button to press. Change anything and it updates by itself.
Do I need to install or sign up for anything?
Not at all — it runs in the browser with nothing to install and no account. After it loads once, it even works without an internet connection.
Is my information private?
Yes. Everything happens in your browser. Nothing you type is sent to a server or saved anywhere.
Common Use Cases
Mailing and guest lists
Paste names or emails from several sources, remove duplicates ignoring case, and sort them: a 7-line list with repeats and a blank line becomes 4 clean lines.
Text from PDFs
Rejoin paragraphs that were broken at every line, straighten curly quotes and collapse double spaces before pasting into a document.
Data wrangling
Turn a comma-separated row into one item per line, or a column into a comma-separated list for a SQL IN (…) clause.
Extracting
Pull every email address or link out of a page of text, without duplicates.
Bulk edits
Add a prefix or suffix to every line, number the lines, or rewrite dates with a regular expression such as (\d+)/(\d+)/(\d{4}) → $3-$2-$1.
Last updated: