How to Fix Text Copied from a PDF (Line Breaks and Spacing)
You copy a couple of paragraphs from a PDF, paste them into a document, and the text is a mess — every line ends abruptly, sentences are chopped into fragments, and there are blank lines everywhere. This is one of the most common and annoying text problems, and it happens for a specific reason. Once you understand why, fixing it takes seconds.
Why PDF text breaks like this
PDFs store text by its visual position on the page, not as a flowing stream of sentences. Each line you see is placed at specific coordinates, and the PDF does not really "know" that one line continues into the next as a sentence. So when you copy, the extraction inserts a line break at the end of every visual line — because as far as the file is concerned, each line is a separate placed object. The result is text broken at every line rather than at every paragraph, often with extra blank lines between them. It is not your fault or the copy function's fault; it is how PDFs represent text.
What 'fixing' it actually means
Fixing PDF-copied text means rejoining the broken lines into proper paragraphs. But there is a subtlety: you want to join the lines within a paragraph while keeping the breaks between paragraphs. Naively removing every line break would merge the entire document into one giant block with no paragraph structure at all — which is worse. The good fix distinguishes a line break inside a paragraph (which should become a space) from the blank line between paragraphs (which should stay). That is what turns broken text back into readable prose.
The tools for the job
Two related cleanups handle it. Removing line breaks rejoins the fragmented lines — the best mode is one that replaces line breaks with spaces within paragraphs while preserving the blank lines that separate paragraphs, so you get flowing text with its structure intact. Then removing empty lines clears out any leftover blank lines the PDF inserted. Run them in that order and messy PDF text becomes clean, readable paragraphs you can actually use.
Other sources with the same problem
PDFs are the worst offender, but the same broken-line problem shows up elsewhere. Text copied from emails, especially forwarded ones, often arrives with hard line breaks at fixed widths. Some web pages and code comments wrap text with real line breaks. Text from older documents and terminal output can do the same. The fix is identical in every case: rejoin the lines within paragraphs, keep the paragraph breaks, and clear the empties. Once you recognize the pattern, you will fix it reflexively.
A clean-text workflow
For thoroughly messy pasted text, a three-step cleanup handles almost anything: remove the extra line breaks to rejoin paragraphs, remove empty lines to clear the gaps, and remove extra spaces to normalize any doubled or stray whitespace the source left behind. Because these tools all run in the browser, you can clean a confidential document without any of it being uploaded. The result is text that looks and behaves as if it were typed cleanly in the first place.