Remove Line Breaks

Join broken lines back into flowing text. Great for text copied out of PDFs.

2 line breaks in the original

Last reviewed:

Why copied text breaks into short lines

A PDF stores text as positioned lines, not flowing paragraphs. When you copy from one, you get a hard line break wherever the page happened to wrap, so a paragraph arrives as eight ragged lines. Plain-text email does something similar: the email standard recommends lines of no more than 78 characters, so older messages and mailing-list posts often arrive hard-wrapped.

Joining the lines puts the text back into sentences. Each line is trimmed, the pieces are joined with a single space, and empty lines are dropped unless you keep paragraphs.

Line breaks vs paragraph breaks

A single line break just starts a new line. A blank line (two breaks in a row) marks a new paragraph. Keeping paragraphs relies on those blank lines: everything between them is joined into one paragraph, and the gaps stay.

OriginalKeep paragraphs onKeep paragraphs off
3 short lines, a blank line, 2 short lines2 paragraphs1 long paragraph
3 short lines, no blank lines1 paragraph1 paragraph
A list with one item per line1 line of items1 line of items

Many PDFs separate paragraphs with a single break, not a blank line, so the paragraphs merge. Press Enter twice at each real paragraph start in the original, then join again.

Fixing words split by hyphens

Books and reports often hyphenate long words at the end of a line. After joining, “infor-” and “mation” become “infor- mation”, with a stray hyphen and space in the middle. A regular expression repairs every one at once.

Example: Rejoining hyphenated words

  1. Open Find and Replace and turn on Regular expression
  2. Find: (\p{L})- (\p{L})
  3. Replace with: $1$2
  4. “This is infor- mation” becomes “This is information”

Every letter-hyphen-space-letter pattern is closed up. Check the match count before copying.

One caution: a word that was hyphenated anyway, like “well-known”, can also break at the hyphen, and the fix would turn it into “wellknown”. Skim the result for compound words before you use it.

Windows, Mac and Linux line endings

Behind the scenes, a line break isn't always the same character. Text that looks identical can end its lines in different ways depending on where it was made, which is why a file can look fine in one program and run together in another.

Line endingCharactersUsed by
CRLFCarriage return + line feedWindows, and many internet protocols including email
LFLine feed onlymacOS, Linux, Android and iOS
CRCarriage return onlyClassic Mac OS before OS X

All three are treated the same here, so text from any system joins correctly.

When to keep the line breaks

Some line breaks carry meaning, and joining them throws it away. A mailing address on four lines becomes one long string a delivery driver has to puzzle over. A poem loses its shape. A recipe's ingredient list turns into a run-on sentence, and code can stop working entirely.

When a document mixes both kinds, join the prose paragraphs on their own and paste the lists, addresses and verses back in separately. It takes a minute longer than joining everything, but you won't have to rebuild a shopping list from a paragraph.

Example: Cleaning a page copied from a PDF report

  1. Clean spaces so justified text loses its gaps
  2. Add a blank line at each real paragraph start
  3. Join lines with Keep paragraphs on
  4. Fix hyphen splits with the regex above
  5. Check the result with the Word Counter

The paragraph count should match the original page, and the word count should be close to the PDF's.

Turning a column into one line

A column of email addresses or product codes copied from a spreadsheet arrives one per line. Joining gives you the items separated by spaces, which is fine for a search box. Most email “To” fields and many forms want commas instead.

Example: From a column to a comma-separated list

  1. Paste the column into Find and Replace and turn on Regular expression
  2. Find: \n
  3. Replace with: a comma and a space
  4. apples, pears and plums on three lines become “apples, pears, plums”

One line, ready to paste into an email or a form.

Some email programs expect semicolons between addresses rather than commas. In that case use a semicolon and a space as the replacement. Either way, glance at the end of the result: a blank line at the bottom of the column leaves a stray separator you'll want to delete.

Clean double spaces with Remove Extra Spaces before joining. PDF text often has both problems, and fixing spaces first keeps the joined text tidy.

Sources and further reading

How to use it

  1. 1Paste the text with unwanted line breaks.
  2. 2Choose whether to keep paragraphs.
  3. 3Copy the joined text.

Questions

Can I keep paragraphs?

Yes. Turn on 'Keep paragraphs' and blank lines between paragraphs are preserved.

Is my text uploaded anywhere?

No. Everything happens in your browser; your text never leaves your device.

Also handy: Text to QR Code, Shuffle a List