G-15 · Text · 6 min read

How to remove line breaks from text copied from a PDF

Fix text pasted from a PDF that breaks at every line: join lines into paragraphs, repair hyphenated words and clean up headers and page numbers.

Fig. G-15 · Text

Copy a paragraph out of a PDF and paste it into an email or a document, and it often arrives as a column of short lines, each ending where the line ended on the printed page. Hyphenated words stay split and page numbers land mid-sentence. This guide explains why that happens and how to turn the text back into clean paragraphs.

Step by step

  1. Copy the text from the PDF and paste it into Remove Line Breaks.
  2. Under Replace line breaks with, keep A space for normal prose. Choose Nothing for text where lines were split mid-word without hyphens, or Custom text to join lines with a separator such as , .
  3. Leave Keep paragraph breaks on so that blank lines between paragraphs survive as a single blank line, while every other line break is joined.
  4. Leave Trim each line and Collapse repeated spaces on to remove the stray spaces PDFs often leave at line ends.
  5. Tick Fix hyphenated breaks (exam-ple → example) if the PDF hyphenates words at line ends.
  6. Compare the Lines before and Lines after counts, read through the result, and copy or download it.

Everything runs in your browser, so you can clean up text from contracts, reports or research papers without uploading them.

Why PDF text has so many line breaks

A PDF describes a printed page, not a flowing document. It records where each run of characters sits, line by line, usually with no notion of a paragraph. When you copy text, the viewer rebuilds the reading order from those positions and puts a line break at the end of each printed line. Emails and plain-text files wrapped at 72 or 80 characters behave the same way, and the same fix works for them.

Several other artifacts come along for the ride:

  • Hyphenated words split across lines, such as docu- and ment.
  • Running headers and footers, such as the document title or chapter name, repeated on every page.
  • Page numbers on lines of their own.
  • Ligatures copied as single characters, such as fi and fl instead of fi and fl, which look right but break searching and spell checking.
  • Soft hyphens (an invisible character, U+00AD) left inside words.

Keeping paragraphs while removing line breaks

The key is telling apart a break that ends a printed line, which should go, from one that ends a paragraph, which should stay. Most PDFs separate paragraphs with an empty line when copied, so with Keep paragraph breaks on, the tool treats one or more blank lines as a paragraph boundary and joins everything else:

Before:
The committee met on 12 March to review
the proposal. After a long discussion it
agreed to proceed with the second option.

Members asked for a revised budget by
the end of the month.

After:
The committee met on 12 March to review the proposal. After a long discussion it agreed to proceed with the second option.

Members asked for a revised budget by the end of the month.

Some PDFs, especially those with indented paragraphs and no spacing, copy without any blank lines between paragraphs. Then there is nothing to tell the two kinds of break apart, and everything becomes one block. Two ways to handle that:

  1. Join only the lines that do not end a sentence. In find and replace, turn on Regular expression, find ([^.!?:])\n and replace with $1 (with a space after it). Every line break that follows something other than ., !, ? or : becomes a space, and lines that end a sentence stay where they are, so each paragraph ends up on its own line. A paragraph in which a sentence happens to end at the end of a printed line will be split in two, so read through the result.
  2. Join everything, then add the few paragraph breaks back by hand. For short passages this is often faster.

Fixing hyphenated line breaks

Typeset PDFs often hyphenate long words at the end of a line. With Fix hyphenated breaks on, the tool joins a line that ends in a letter followed by - with the next line when that next line starts with a lower-case letter, removing the hyphen. So docu- + ment becomes document.

The lower-case rule protects terms like Franco- + Prussian. It cannot tell, though, whether a hyphen belongs to the word. A genuinely hyphenated term that happens to break at its hyphen, such as self- + aware, also becomes selfaware. After joining, search the result for words that look wrong. A find and replace for selfaware → self-aware fixes every occurrence at once.

If the PDF used soft hyphens instead of visible ones, the words may already look joined but contain an invisible character that breaks searching. Remove them with find and replace in regex mode: find \u00AD and replace with nothing.

Cleaning up headers, page numbers and leftovers

Do this cleanup before joining lines, while each header and page number is still on its own line and easy to match. A good order of work:

  1. Remove page numbers. In find and replace, turn on Regular expression and the m multiline flag, find ^[ \t]*\d+[ \t]*$ and replace with nothing. That empties every line that contains only a number. If pages are numbered like Page 4 of 12, use ^Page \d+ of \d+$.
  2. Remove running headers. If the header is the same text on every page, a plain-text find and replace with an empty replacement removes every copy. Make sure the text does not also appear inside the body, and turn on Match case if that helps keep the two apart.
  3. Fix ligatures. Replace fi with fi and fl with fl in plain-text mode. Copy the ligature character from your pasted text to search for it.
  4. Join the lines with Remove Line Breaks as described above. Empty lines created by the first two steps are handled: a run of blank lines counts as a single paragraph break, and with Keep paragraph breaks off they are dropped. Where a page break fell in the middle of a paragraph, the emptied lines leave a false paragraph break; join those few by hand.

For a list rather than prose, such as names or references copied from a table, keep one item per line. Join only the broken items, then use Remove Duplicate Lines to drop repeated entries (with Case sensitive off if Smith and SMITH should count as the same), and Sort Lines to put them in order.

Tip Some viewers interleave lines from both columns of a two-column PDF. Joining lines will not fix that; select one column at a time instead.

When the text is clean, the word counter checks its length (see how to count words and characters). To combine whole documents instead, read how to merge PDF files.

FAQ

Common questions.

01How do I keep paragraphs but remove the other line breaks?

Leave Keep paragraph breaks on. One or more blank lines count as a paragraph break and become a single blank line, and every other line break is replaced with a space or the separator you choose.

02Why are some words joined without a space after removing line breaks?

You probably chose Nothing as the replacement, or the hyphen fix joined a word that was hyphenated on purpose. Use A space for normal text, and check words like selfaware after using the hyphen fix.

03Can I turn a column of values into a comma-separated list?

Yes. Choose Custom text under Replace line breaks with and type a comma and a space. Turn off Keep paragraph breaks if the list contains blank lines, so they are dropped rather than kept.