How to remove line breaks from text

Paste the text into the Text Toolkit. If you want one continuous block, switch find-and-replace to Regex mode, find \s*\n\s* and replace it with a single space.

If you want to keep the paragraph breaks, use Trim lines first, then find (?<!\n)\n(?!\n) and replace with a space. That pattern matches a newline that has no newline on either side — that is, a mid-paragraph wrap — and leaves the double newlines between paragraphs alone.

Last reviewed: 2026-09-19. Checked against the tool’s own source on that date.

Why text arrives with hard line breaks

Copying out of a PDF is the usual source. A PDF has no paragraphs — it has text positioned on a page — so the copy inserts a newline wherever a visual line ended. A paragraph that occupied six lines on the page arrives as six lines of text.

Plain-text email is the other common source. Older mail clients hard-wrapped outgoing messages at 72 or 76 characters, and quoted replies preserve those breaks indefinitely.

The distinguishing feature is that the breaks fall mid-sentence, at roughly the same column, rather than at sentence ends. That is what makes them mechanically removable: real paragraph breaks are separated by a BLANK line, and mid-paragraph wraps are not. Everything below rests on that difference.

Keeping the paragraphs: the one-pattern method

The pattern reads: a newline that is not preceded by a newline and not followed by one. A mid-paragraph wrap matches; each newline in a double break has a newline on one side, so neither matches.

If the tool rejects the pattern with an error, your browser does not support lookbehind. In that case use the simpler \s*\n\s* replacement to join everything, and re-introduce the paragraph breaks in whatever you paste the text into.

  1. Press Trim lines. This strips leading and trailing whitespace from every line, so a paragraph separator becomes exactly two newlines rather than a newline, a stray space and another newline.
  2. Tick Regex.
  3. Find (?<!\n)\n(?!\n) and replace with a single space. Press Replace all.
  4. Check the count. It should roughly match the number of wrapped lines, and it should be smaller than your total line count by about the number of paragraphs.

Joining everything into one block

For a quotation, a search query or anything going into a single field, you do not need to protect paragraphs at all.

Regex mode, find \s*\n\s* and replace with a single space. The \s* on both sides absorbs the indentation and trailing spaces at the same time, so you do not need a separate double-space cleanup afterwards.

Windows line endings, and other things that go wrong

  • If a replacement on \n reports zero, or leaves stray characters behind, the text has Windows line endings. Find \r and replace it with nothing first; that converts CRLF to LF and the patterns above then behave.
  • Hyphenated words split across lines — "inter-" then "national" — become "inter- national" after joining. Find "- " and replace with nothing, but read the count first, because that pattern also matches legitimate dashes in prose.
  • Double spaces can survive if a line ended with a space and you used the lookbehind pattern. Find two spaces, replace with one, and run it twice.
  • Text with no blank lines between paragraphs has no signal to protect. No pattern can recover a paragraph boundary that was never encoded, and you will have to reinsert those by hand.

Two things about this tool’s regex mode

Patterns are compiled inside a guard. An invalid pattern gives you an error message and leaves your text exactly as it was — a lone open bracket is a normal intermediate state while typing, and it should not destroy your work.

Patterns are compiled with the global flag and without the multiline or dotall flags. A replacement therefore always applies everywhere; the dot does not match a newline; and ^ and $ anchor to the whole text rather than to each line. To act per line, match the newline explicitly, which is what the patterns above do.

The find and replace fields are single-line inputs. You can MATCH a newline with \n, but you cannot INSERT one — a \n typed into the replacement field is inserted as a backslash followed by an n. That is why the method above never needs to put a newline back.

Worked example: two paragraphs copied out of a PDF

The pasted text has a hard break after every printed line and one blank line between the two paragraphs. Using / for a newline, it looks like this:

"The committee met on Tuesday to review the / proposal submitted in March. Several members / raised concerns about the timetable. / / A revised version will be circulated before / the next meeting."

There are five newlines in total: four wraps and one paragraph break written as two consecutive newlines. Four of the five should go.

  1. Press Trim lines.
  2. Tick Regex, find (?<!\n)\n(?!\n), replace with a space, Replace all.
  3. Read the reported count.

Result: The tool reports 3 replacements — the three mid-paragraph wraps — and the result is two paragraphs, each on one continuous line, still separated by a blank line. Using \s*\n\s* instead would have reported 4 and merged both paragraphs into one, which is the right answer for a quotation and the wrong one here.

Open the tool

Clean up text in the Text Toolkit

Literal and regex find-and-replace with an undo history and a replacement count after every step. Nothing you paste is sent anywhere.

What this does not cover

  • This is find-and-replace, not reflowing. It cannot tell a mid-sentence wrap from a deliberately short line such as an address block, a verse or a bulleted list.
  • The replacement field cannot insert a newline, so any technique that needs to put line breaks back has to finish somewhere else.
  • The lookbehind pattern needs a browser that supports lookbehind assertions. An older browser reports an invalid-pattern error rather than failing silently.
  • Processing runs on the main thread, so a very large document may pause the interface briefly during a transformation.
  • Undo is limited to the last 50 operations.
  • Nothing is saved between visits. Reloading the page discards your work, by design.