Remove Line Breaks

Remove line breaks from text

Strip line breaks out of pasted text — great for cleaning up copied PDFs, emails, and code comments.

▌ Input
▌ Output

How it works

Paste text on the left and the cleaned version appears on the right. Choose whether to join lines with a space, remove blank lines, and collapse repeated spaces. Then copy the result.

This pairs well with the other text tools: tidy capitalization with the case converters, flip text with the reverse text tool, or sort and dedupe a list with alphabetize. For everything in one place, use the text transformer.

When you need it

Text copied out of PDFs, emails, code comments and chat logs often arrives with a hard line break at the end of every line, which becomes a mess when you paste it into a document, a spreadsheet cell, or a form field that expects one continuous paragraph. Stripping those breaks — while keeping the real paragraph breaks — turns broken-up text back into clean, flowing prose.

The options, explained

Join with a space replaces each break with a space so words don't run together; remove blank lines collapses the empty gaps left behind; and collapse repeated spaces tidies the double spaces copying often introduces. Combine them to go from a jagged paste to a single clean block in one step, all in your browser.

Why PDF text arrives broken

A PDF has no paragraphs. It stores glyphs at coordinates on a page, and the visual line breaks you see are a consequence of where each piece of text was placed, not of any structure in the document. When you copy, the extractor has to guess where lines end, and it generally inserts a hard break at every visual line — so a justified paragraph becomes a dozen short lines.

The same thing happens with plain-text email, which traditionally hard-wraps at around 72 characters, and with text pulled out of code comments or chat logs. In every case the breaks are an artefact of how the text was displayed, not part of its meaning, which is why removing them restores the original paragraphs.

Hyphenation is the one case to watch. If a PDF broke a word across lines, joining them leaves a stray hyphen mid-word — worth a quick scan afterwards.

Keeping the breaks that matter

The distinction the tool relies on is that a single newline is usually an unwanted wrap while a blank line (two newlines) marks a real paragraph boundary. Joining single breaks and preserving doubles therefore reconstructs the paragraphing correctly most of the time.

  • Turn off "remove blank lines" to keep paragraph separation intact.
  • "Join with a space" is what you want for prose; joining with nothing is for reassembling a value that was split mid-string, such as a long token or a base64 blob.
  • "Collapse repeated spaces" cleans up the double spaces that appear where justified text was extracted.

Text that was never prose — a list, a code block, a table — should keep its breaks, since each line is meaningful there. Run those through the alphabetize tool or the CSV converter instead.

The invisible characters that cause trouble

Line endings differ by platform: Windows uses a carriage return plus line feed (CRLF), Unix and macOS use a bare line feed (LF). Mixed endings in one file are common when text has passed between systems, and they cause odd behaviour in editors and version control even though nothing looks wrong on screen.

Text copied from the web can also carry non-breaking spaces (U+00A0) that look exactly like ordinary spaces but do not wrap and do not match a normal space in a search — a frequent cause of a find-and-replace mysteriously failing. Cleaning text through this tool normalises the obvious whitespace problems; for case and other transformations, the text transformer handles the rest.

FAQ

Why does copied PDF text have weird line breaks?
PDFs store hard line breaks at the end of every visual line. This tool removes them so the text flows as continuous paragraphs.
Can I keep paragraph breaks?
Yes — leave 'Remove blank lines' unchecked and only the within-paragraph breaks are joined.
Why does text copied from a PDF have line breaks everywhere?
Because a PDF stores glyphs at positions on a page rather than paragraphs. When you copy, the extractor guesses where lines end and inserts a hard break at every visual line, so a single paragraph arrives as a dozen short ones.
How do I remove line breaks but keep paragraphs?
Keep blank lines and join only single breaks. A single newline is usually an unwanted wrap, while a blank line marks a genuine paragraph boundary — so turning off "remove blank lines" preserves the paragraphing while tidying the wrapped text.
What is a non-breaking space and why does it cause problems?
It is U+00A0, a space that prevents a line break. Text copied from the web often contains them, and because they look identical to ordinary spaces but do not match one in a search, they are a common reason find-and-replace appears to fail.

Related tools