Remove Line Breaks

Paste text that has hard breaks in the middle of sentences and join it back into flowing text — with a space, with nothing, or by collapsing only the blank lines.

What this tool does

Copying text out of a PDF, a newsletter or a web page often brings the source's line breaks with it, so every line ends where the layout ended rather than where the sentence ends. Pasting that into a document, an email or a database gives you ragged lines that reflow badly and break search. This tool removes those hard breaks and rejoins the text, in one of three ways.

It is the everyday companion to the other tools here: use it to clean a paragraph before counting it, transliterating it or running it through a spreadsheet.

Method

The input is normalised to Unix newlines, then handled according to the chosen mode: space replaces every run of newlines with a single space and collapses the leftover double spaces; none removes the newlines entirely, for text where a break fell in the middle of a word; paragraph keeps one newline between blocks and drops the blank ones, preserving genuine paragraphing. Trailing whitespace is trimmed in every mode.

ModeInputOutput
spacea\nba b
nonea\nbab
paragrapha\n\nba\nb

Example

InputJoin with a space
This is a sentence that was
broken across three lines
by the PDF.
This is a sentence that was broken across three lines by the PDF.

Why PDFs and emails arrive this way

A PDF has no paragraphs — it has positioned glyphs and instructions to move the cursor to the next baseline. When a viewer copies text, it inserts a newline at every one of those moves, so the breaks follow the typeset layout rather than the sentence. The same happens with HTML that uses <br> for layout instead of paragraphs, and with plain-text email that was hard-wrapped at 72 columns by the sender's client.

The breaks are real characters in the paste, not a rendering artefact, which is why the fix has to delete them. A text area that visually wraps a long line does not insert anything — if you paste a paragraph and it wraps, there is nothing to remove. The tool is for the case where the newlines are present in the text itself.

Where joining goes wrong

Joining lines is a guess about why the line ended, and three cases defeat the guess:

  • Hyphenation. A PDF that hyphenated con-tinue across a line leaves con- and tinue. Joining with a space produces “con- tinue”; joining with nothing produces “con-tinue”. Neither restores the original word — removing the hyphen requires a dictionary, which this tool deliberately does not ship.
  • Line breaks that were meant. Addresses, code, poetry, lists and signature blocks need their breaks. Joining a postal address turns four lines into an unreadable sentence.
  • Unicode line separators. U+2028 LINE SEPARATOR and U+2029 PARAGRAPH SEPARATOR are legal line endings that JavaScript treats as breaks but that are not the \n this tool matches. Text copied out of some JSON payloads, databases and word processors carries them, and they will survive every mode here. The Whitespace & invisible cleaner removes them; run that first if joining seems to have no effect.

Choosing a mode

Join with a space is the right default for prose: a sentence that wrapped at the page margin had a space at that position, and putting one back is the faithful reconstruction. It is wrong for CJK text, where a wrap does not imply a space and inserting one changes the text.

Join with nothing exists for the case where a break fell inside a word or an identifier — a wrapped URL, a long path, a code token split across lines. Applied to prose it welds words together, so it is a targeted repair rather than a general one.

Collapse blank lines keeps the text's own line structure and only removes the empty lines between blocks. Use it when paragraphs were separated by two or more newlines and you want one. It does not join anything, so a paragraph still wrapped at 72 columns stays wrapped.

What it will not fix

Smart quotes stay smart, non-breaking spaces stay non-breaking, and runs of ordinary spaces inside a line are left alone in the “nothing” and “paragraph” modes. Ligatures that arrived as single characters, page numbers that got pasted in mid-paragraph and repeated headers from a PDF are all content problems, not line-break problems. For those, the Whitespace & invisible cleaner and Line Tools pages handle the character-level and line-level clean-up respectively.

Frequently asked questions

What does this tool do?

It removes line breaks from pasted text — the newlines that creep in when you copy from a PDF, an email or a web page and end up with a hard break in the middle of every sentence. You choose whether to join the lines with a space, with nothing, or just collapse blank lines.

Which mode should I pick?

Use "Join with a space" when the breaks split sentences (the usual case for PDFs), "Join with nothing" when the breaks split words or codes, and "Collapse blank lines" when you want to keep real paragraphs but lose the extra empty lines.

Does it touch single line breaks inside paragraphs?

The space and none modes remove every line break. The paragraph mode keeps one break between blocks and removes only the blank ones.

Will it change my spaces?

In space mode, runs of spaces that appear after joining are collapsed to one, and the result is trimmed, so you do not get a double space where a line ended. Nothing else is altered — no smart quotes, no reflowing.

Is my text uploaded?

No. The whole conversion runs in the page, so the text never leaves your device.

Can I remove only some breaks?

This tool is all-or-nothing per mode by design, because deciding which breaks are "wrong" needs a word dictionary. If you need finer control, use the Line Tools page, which sorts, deduplicates and reverses lines instead of joining them.

Sources

  • Unicode Standard — line breaking (UAX #14) for the definition of the line-break characters handled here.
  • WHATWG Encoding Standard — for newline normalisation (CRLF and CR to LF).

Everything runs in your browser — nothing you type is uploaded.