TextSorter

How to Remove Line Breaks from Text (Copy Paste Fix for PDF, Word, Email)

· 7 min read

You know that thing where you copy text from a PDF and paste it into an email, and suddenly every single line ends in a random spot? Like the text just decided paragraphs are overrated?

Yeah. That’s not your fault. And it’s not a bug on your computer. It’s actually how PDFs work under the hood, and it drives basically everyone insane.

Why Pasted Text Gets Those Weird Line Breaks

Here’s what’s happening. A PDF is not a text document. Not really. It’s more like a picture of a document that happens to have selectable text layered on top. Think of it like a very fancy screenshot with invisible text boxes scattered around.

When the PDF was created (whether from Word, InDesign, Google Docs, or whatever), the software positioned each line of text at specific coordinates on the page. Line 1 goes at position Y=720, line 2 at Y=700, and so on. The PDF has no concept of “flowing paragraphs.” It just knows “put these characters at this exact spot.”

So when you select text and hit Ctrl+C, your computer does its best to reconstruct the reading order. It grabs each positioned text chunk and slaps a hard newline character at the end. Every. Single. Line.

The result? A paragraph that originally looked like this:

“The quarterly results exceeded expectations with a 23% increase in revenue compared to the previous fiscal year.”

Turns into this nightmare after pasting:

The quarterly results exceeded
expectations with a 23% increase
in revenue compared to the
previous fiscal year.

Four lines instead of one sentence. And now you get to fix it manually. Fun times.

The Actual Technical Reason (For the Curious)

If you want the nerdy explanation: it comes down to the difference between hard returns and soft returns.

A hard return is a literal newline character (technically \n on Unix/Mac or \r\n on Windows). It’s an actual invisible character sitting in the text that says “new line starts here.” When you hit Enter in any text editor, you create a hard return.

A soft return (also called a “word wrap”) is purely visual. Your text editor wraps text to the next line when it reaches the edge of the window. No actual character gets inserted. If you widen the window, the text reflows.

PDFs throw this distinction in the garbage. Every visual line ending becomes a hard return when you copy. And that’s the root of the whole problem.

Microsoft Word does something similar but slightly different. Word uses \r (carriage return, ASCII 13) for its line breaks internally, plus paragraph marks. When you paste from Word into a plain text field, you sometimes get a mix of \r\n, \r, and \n characters, which is why pasted Word text can behave differently across platforms.

How to Fix It (The Fast Way)

The quickest method is an online tool. Seriously. I know that sounds like I’m just pitching something here, but think about the alternatives:

Method 1: Manual fixing — Go through and delete each line break one by one, adding spaces where needed. If your text is 3 paragraphs long, fine. If it’s 12 pages of a research paper? You’ll lose an hour of your life you won’t get back.

Method 2: Find and Replace in Word — Open Word, paste the text, hit Ctrl+H. Type ^p in the Find field (that’s Word’s code for a paragraph mark). Type a space in the Replace field. Click Replace All. Then go back and re-add the paragraph breaks you actually wanted. It works, but you need to know the ^p and ^l syntax, and you’ll probably need multiple passes.

Method 3: Use a line break remover tool — Paste the text, click one button, done. No syntax to memorize. No accidental over-replacing. Copy the cleaned text and move on.

TextSorter’s Clean Text tool handles this in about 3 seconds. Paste your mangled text, and it removes the unwanted line breaks while keeping your real paragraph breaks. Everything runs in your browser, so if you’re working with confidential stuff like legal briefs or medical records, nothing gets sent anywhere.

When Does This Problem Actually Show Up?

It’s way more common than you’d think. Some real situations where broken line breaks ruin your day:

Emails. You copy a section from a contract PDF to quote it in an email, and the recipient gets a message that looks like it was formatted by a typewriter with a broken return key.

Academic papers. You’re pulling quotes from journal articles (which are almost always PDFs), and every citation has random line breaks that mess up your reference formatting.

Legal work. Lawyers copy clauses from PDF contracts into new documents constantly. Those line breaks can actually change meaning in legal text if they split a defined term across two lines.

Data entry. Someone sends you a PDF with a list of addresses or product descriptions. You paste them into a spreadsheet or CRM, and every entry has random line breaks in the middle of fields.

Coding. You copy a block of text from documentation (often served as PDF) into a string variable, and now you’ve got \n characters in places that break your string.

The Different Types of Line Breaks (And Why It Matters)

Not all line breaks are created equal. Your computer uses different invisible characters depending on the operating system and the source of the text:

LF (Line Feed) is \n, ASCII code 10. This is the Unix/Linux/macOS standard. One character, one job: move to the next line.

CR (Carriage Return) is \r, ASCII code 13. This is a leftover from actual typewriters. The “carriage” was the thing that held the paper, and “return” meant sliding it back to the left margin. Old Mac systems (pre-OS X) used just \r.

CRLF is \r\n, which is both characters together. Windows uses this combo. Yes, Windows needs two characters to do what Unix does with one. There’s a historical reason involving teletype machines, but honestly it just creates confusion in 2026.

When you paste text from a PDF, you might get any of these. Or a mix. And when you paste that into a different system (like a web form that expects \n only), things get weird. Characters that are invisible to you can cause text to display with phantom blank lines or refuse to align properly.

A good text cleaning tool handles all three variants automatically. TextSorter’s Clean Text tool normalizes everything regardless of which line break flavor your source used.

How to Remove Line Breaks Without Losing Paragraph Spacing

This is the tricky part. If you just blindly replace all \n characters with spaces, you’ll merge everything into one giant blob of text. Your carefully separated paragraphs become one unreadable wall.

The smart approach: replace single newlines with spaces (those are the broken mid-sentence line breaks) but keep double newlines (those mark actual paragraph boundaries).

Here’s the logic:

  1. First, normalize all line break types to \n
  2. Find runs of two or more \n in a row (those are paragraph breaks) and temporarily replace them with a placeholder
  3. Replace all remaining single \n with a space
  4. Put the paragraph breaks back
  5. Clean up any double spaces that got created

If you’re doing this in code, the regex version looks like:

text.replace(/\n{2,}/g, 'PARAGRAPH_BREAK')
    .replace(/\n/g, ' ')
    .replace(/PARAGRAPH_BREAK/g, '\n\n')
    .replace(/  +/g, ' ')

Or, you know. Just paste it into TextSorter’s Clean Text tool and let it handle the logic. Especially if regex makes your eyes glaze over.

Removing Line Breaks in Google Docs

If you’re a Google Docs person, here’s how to do it there:

  1. Paste your broken text into a Google Doc
  2. Open Find and Replace with Ctrl+H (or Cmd+H on Mac)
  3. Check the “Match using regular expressions” box
  4. In the search field, type \n (this won’t catch paragraph marks, just line breaks within paragraphs)
  5. In the replace field, type a single space
  6. Click “Replace all”

One catch: Google Docs’ regex support is limited compared to a dedicated tool. It handles simple cases fine, but complex text with mixed line break types might need a couple of passes.

Removing Line Breaks in Excel

Excel has its own approach. If you’ve pasted multi-line text into a cell and want to flatten it:

Formula method: Use =SUBSTITUTE(A1, CHAR(10), " ") to replace line feeds, or =CLEAN(A1) to strip all non-printable characters. To handle both CR and LF, chain them: =SUBSTITUTE(SUBSTITUTE(A1, CHAR(13), ""), CHAR(10), " ")

Find and Replace method: Select the cells, Ctrl+H, in the Find field press Ctrl+J (this inserts a line break character you can’t see), leave Replace empty or put a space, hit Replace All.

That Ctrl+J trick is one of those things that basically nobody knows about but saves serious time if you work with imported data.

Common Mistakes People Make

Mistake 1: Replacing ALL line breaks including paragraph breaks. You end up with one infinite paragraph. Always distinguish between single breaks (mid-sentence) and double breaks (real paragraphs).

Mistake 2: Forgetting to add a space. If you just delete the line break without replacing it with a space, you’ll fuse the last word of one line with the first word of the next. “quarterly” and “results” become “quarterlyresults.” Not great.

Mistake 3: Not handling the Windows CRLF. If you only search for \n but the text uses \r\n, you’ll leave orphan \r characters that show up as weird formatting or ^M symbols in some editors.

Mistake 4: Breaking intentional line breaks. Poetry, code snippets, addresses, and lists use line breaks on purpose. Check your output to make sure you haven’t accidentally merged things that should stay separate.

The Bottom Line

Broken line breaks from PDFs, Word docs, and emails are one of those tiny problems that wastes a shocking amount of cumulative time. The fix takes literally 3 seconds with the right tool.

Paste your text into TextSorter’s Clean Text tool, grab the cleaned version, and get back to the work that actually matters. It runs in your browser, never touches a server, and you don’t need to give your email to anyone.

If you deal with messy text regularly, also check out the Remove Extra Lines tool (for stripping blank lines) and the Strip HTML tool (for cleaning text copied from web pages that brings along invisible HTML tags).

Fix your broken line breaks now with Clean Text →