ToolsTray

Star a tool to keep it here.

Text Cleaner

A text cleaner for pasted mess: pull the hard line breaks out of PDF copy, squash double spaces, thin the blank lines, and swap curly quotes for straight ones.

Cleaned text

The cleaned text appears here.

What changed is counted below.

Clean-up options

Typed straight in — a dollar sign is a dollar sign.

What changed

—

nothing pasted yet

How to use

  1. Put the messy text in the Text to clean box. The cleaned copy and the count of what changed are there from the start, waiting for something to work on.
  2. Leave the four ticked boxes as they are for a light tidy, or start toggling. When a stronger box makes a weaker one pointless, the weaker one says so on its own row and keeps its tick for later.
  3. Tick Remove line breaks when sentences arrived broken in half. It throws away the empty lines and joins the rest with a single space.
  4. Read the result in Cleaned text. It redraws on every keystroke and on every checkbox you touch.
  5. Optional: type something into Find and its replacement into Replace with. Tick Use a regular expression first if you want a pattern rather than literal text.
  6. Press Copy cleaned text when the result looks right.

About this tool

Copy a paragraph out of a PDF, paste it into an email, and what lands is rarely what you saw. A hard line break every sixty characters. Double spaces left over from the justification. Curly quotes that will break a CSV import later. Paste it into the text cleaner instead, tick the fixes you want, and a repaired copy builds itself in Cleaned text beside it while you type, with every character the cleaning took out marked where it sat.

Four boxes are already ticked when the page loads. Trim each line, Collapse extra spaces and Collapse blank lines make up the light tidy most pasted text needs, and Remove invisible characters takes out the zero-width spaces, word joiners, soft hyphens and stray byte order marks that ride along with web and PDF text. Zero-width joiners and non-joiners stay, named, because emoji sequences and some scripts need them. The other three start off, because each one changes the shape of the document rather than just its spacing: Remove blank lines, Remove line breaks and Straighten smart quotes.

Find sits under the boxes, with a Use a regular expression check beside it. Leave the check off and Find swaps exact text, a dollar sign meaning a dollar sign. Tick it and your pattern becomes a real regular expression, with capture groups coming back as $1 and $2 in Replace with. Either way every hit is marked in the text you pasted, and the count sits in the strip under the two panes.

The order the fixes run in is fixed and worth knowing. Per-line trimming and space collapsing go first, then the blank-line rules, then the join and the quote swap. Find and replace comes last, working on whatever survived. Toggle the boxes in whatever sequence you like; the same input and the same ticks give you the same output every time. The word counter next door will tell you what you ended up with.

A PDF abstract, put back together

Four lines of an abstract arrive with a hard return at the end of each one and a stray double space after every full stop. Tick Remove line breaks on top of the defaults and the whole thing comes back as one paragraph with single spaces throughout, because the join drops the empty lines first and then squeezes the whitespace that lands at each seam.

Now suppose the paper writes behaviour and your style guide wants behavior. Type behaviour into Find, behavior into Replace with. Every hit is marked in the paste and the strip reads 6 replacements, so you can check the damage before you copy anything.

Good to know

  • Whitespace and quote characters are the whole job here. No spell check, no rewording, and a word that a PDF hyphen-split across a line end stays split.
  • Remove blank lines beats Collapse blank lines when both are ticked, and Remove line breaks beats both. You get no blank lines at all rather than one between paragraphs, which is why the overridden box says so on its row.
  • The paste marks the first 500 hits and then stops marking. The count in the strip is still the real total, and the replacement still applies to all of them.
  • Find and replace sees the cleaned text, not what you pasted. Search for two spaces while Collapse extra spaces is on and you will find nothing, because there is only one space left by then.

Frequently asked questions

How do I remove line breaks from text copied out of a PDF?

Tick Remove line breaks. Every non-empty line gets joined with one space and the empty ones are dropped, so four short broken lines turn back into the sentence they were before someone exported the page.

Can I keep my paragraphs and only close up the big gaps?

That is what the page does out of the box. Collapse blank lines rewrites any run of two or more empty lines as a single empty line, so the paragraph breaks survive and the ugly double spacing from pasting goes away. Just leave Remove blank lines unticked.

Which characters does Straighten smart quotes actually change?

Eight of them, in two groups. The curly singles ‘ ’ plus their low and reversed cousins ‚ ‛ all become a straight apostrophe, and “ ” „ ‟ all become a straight double quote. Everything else is left alone, which is what CSV parsers and code editors want.

Does the regex mode support capture groups?

Yes. Tick Use a regular expression, write the pattern in Find, then reference the groups as $1, $2 in Replace with. Turning 2026-07-06 into 06/07/2026 takes (\d+)-(\d+)-(\d+) and $3/$2/$1. A pattern that fails to compile is explained under the Find box, and the last good result stays put, dimmed, until you fix it.

Why did my regular expression give up on a long document?

Regex runs in a background worker with a 1.5 second ceiling, so a pattern that backtracks badly on a big paste gets cut off rather than freezing the page. Nested quantifiers like (a+)+ are the usual cause. Anchor the pattern or narrow it and it will finish in milliseconds.

Missing something in Text Cleaner? Suggest a feature →

Tell someone who needs this.