Replace each line break with a space. For one paragraph, copy the text and pick Remove Extra Spaces in the Clip Text Transform menu: breaks and double spaces become single spaces. For several paragraphs, use a find & replace rule that joins lines but keeps the empty line between paragraphs. Pages can also do it with Find & Replace.
You copy a paragraph out of a PDF, paste it, and it arrives as a stack of short lines — sometimes with double spaces where the lines met and words split with a hyphen at the end of a line. Retyping it by hand is slow, and deleting the breaks one at a time is slower. The fixes below take a minute — the right one depends on how much text you copied.
Which fix to use. One paragraph: Remove Extra Spaces. Words split with a hyphen: Fix OCR word-break first, then join. Several paragraphs: the rule further down, saved once as your own script.
The built-in way: Find & Replace in Pages
If you have Pages — Apple's word processor, which isn't installed on every Mac — its Find & Replace can search for line breaks by code and replace them with text.
- Paste the text into a Pages document.
-
Open Find & Replace and search for
\n, Pages's code for a paragraph break. Pages treats every line of text pasted from a PDF as a paragraph of its own, so\nfinds the break at the end of each line. - Type a single space in the replace field and replace all matches. Copy the text back out when you're done.
The limit of this way: Pages can't tell the end of a line from the end of a paragraph here — both are
\n. Replacing them all joins everything you pasted into one block,
paragraphs included. That's what you want for one paragraph; for several, use the rule below, which keeps the empty
line between them.
Do it from the menu bar with Clip Text Transform
Copy the text, pick the fix in the menu bar, paste. Which fix depends on what you copied.
One paragraph
Pick Remove Extra Spaces. Every line break and every run of spaces becomes a single space, and spaces at the start and end are trimmed.
Words split with a hyphen
A word broken across two lines — doc- at the end of one, ument at the start of the next —
needs its own fix. Add Fix OCR word-break from the Script Library once
(Manage Custom Scripts… → Script Library → select it → Add), and it's an item in your menu from then on.
Run it before you join the lines: once a break has turned into a space, the hyphen stays behind as
doc- ument.
Several paragraphs
When the text has more than one paragraph, you want the breaks inside each paragraph gone and the empty line between paragraphs kept. That's one regex rule, saved once as your own script: choose Manage Custom Scripts…, then Add New, give the script a name, and fill in —
-
Find:
[ \t]*(?<![\r\n])\r?\n(?![\r\n])[ \t]* - Replace: a single space
- Regular Expression: on
Before you save, paste a few lines of your text under Testing — the result updates as you type, so you can see the paragraphs stay apart.
In plain words: a line break with no other line break right before or after it — plus any spaces or tabs around it — becomes one space. A break next to another break is the empty line between paragraphs, so it stays.
line one
line two
next para
more
line one line two
next para more
It works the same on text with Windows-style line endings, and spaces left at the end of a line don't turn into double spaces. Save it, and next time it's copy, click, paste. This is a find & replace rule that keeps your paragraphs — the kind of rule you can build for other fixes you repeat.
What to watch out for
Remove Extra Spaces joins paragraphs too. It turns every line break into a space, so a text with several paragraphs comes out as one long line. The ready-made Join lines (line breaks to space) in the Script Library does the same with the breaks. For more than one paragraph, use the rule above.
An empty line has to be really empty. If the line between two paragraphs holds a space or a tab, the rule doesn't see it as a paragraph break, and the two paragraphs are joined.
Split words aren't joined by the rule. It turns doc- + line break +
ument into doc- ument. Run Fix OCR word-break
first.
A break at the very end becomes a space. If the copied text ends with a line break, the result ends with a space.
Extra empty lines stay. Two or more empty lines between paragraphs are kept as they are.
The joining happens on your Mac, and the text you fix stays on your Mac — see the Privacy Policy.
PDF line breaks are one of many small fixes — see more everyday text tasks you can do on your Mac.