textscrubr
Home / Blog / Text tools

How to Remove Line Breaks From Text

Text tools2 min readUpdated 2026-06-24
To remove line breaks from text, use find-and-replace to swap line breaks for spaces, or a cleaner that collapses hard-wrapped lines while keeping real paragraph breaks. Text copied from PDFs and emails often has a break at the end of every line; removing them rejoins the paragraphs.

Text copied from PDFs, emails, and some documents often has a line break at the end of every line, so paragraphs arrive chopped into pieces. Here is how to fix it.

Why the breaks are there

Some sources hard-wrap text: they insert an actual line break at the end of each visible line rather than letting it flow. When you paste that text somewhere with a different width, the breaks stay, and you get a paragraph broken into short, ragged lines.

There are two kinds of break to know about:

The careful way to remove them

The trick is removing the breaks inside paragraphs while keeping the breaks between them. In an editor with regex:

  1. First protect paragraph breaks: replace two line breaks with a placeholder.
  2. Replace remaining single line breaks with a space.
  3. Restore the paragraph breaks from the placeholder.

This rejoins each paragraph into a flowing block without merging separate paragraphs into one.

The simple way

If you do not want to fight with regex, paste the text into a cleaner. A cleaner can collapse the runaway breaks and normalize spacing while keeping the real structure. textscrubr also strips the invisible characters and fixes the spacing that copied PDF and email text usually brings along, so you get clean, rejoined paragraphs in one pass.

Watch out for lists and code

Blindly removing every line break will destroy bulleted lists and code, where line breaks are meaningful. A structure-aware approach keeps the breaks that belong to lists and code and only rejoins ordinary prose, so you do not flatten your formatting while fixing the wrapping.

Quick recap

Remove single breaks inside paragraphs, keep double breaks between them, and protect lists and code. A cleaner handles all three at once so hard-wrapped text becomes clean, flowing paragraphs.

Scrub this text in one click

textscrubr strips the hidden characters, em dashes, and double spaces, and keeps your lists, headings, and code exactly where you put them. Free, and it runs entirely in your browser.

Clean my text free →

Frequently asked questions

How do I remove line breaks but keep paragraphs?

Remove single line breaks inside paragraphs while keeping the double breaks between them. With regex, protect double breaks first, replace single breaks with a space, then restore the paragraph breaks.

Why does text from a PDF have a break on every line?

Because the source hard-wraps text, inserting an actual line break at the end of each visible line. When pasted elsewhere, those breaks stay and chop the paragraph into pieces.

Will removing line breaks ruin my lists?

It can if you remove every break blindly, since lists and code rely on line breaks. A structure-aware cleaner keeps those and only rejoins ordinary prose.