Skip to content
UniKit

Stray line break remover

Replace the stray single line breaks that OCR, PDF or web copy leave inside a paragraph with a space or your own separator, keep blank lines as paragraph breaks, and report how many breaks were joined.

Runs in your browserEvery computation happens in your browser — your data never leaves this device.

Text with stray line breaks

Cleaned text

Single line breaks inside a paragraph become the separator; two or more line breaks are kept as paragraph breaks.

Paste text to remove the stray line breaks

What this tool does

  • Fix whole paragraphs that OCR or PDF copy turned into one line per sentence
  • Remove hard line breaks picked up when copying from chat apps or web articles while keeping blank lines between paragraphs

Example

Input

This paragraph was
split by OCR.

This is the second one,
broken the same way.

Output

This paragraph was split by OCR.

This is the second one, broken the same way.

Single breaks inside a paragraph become a space; blank lines stay as paragraph breaks. The stats report 3 in-paragraph breaks joined and 1 paragraph break.

Frequently asked questions

How does it decide which line breaks are stray?

The rule is deterministic: CRLF and CR are normalized to LF, two or more consecutive line breaks are treated as a paragraph break and kept, and every remaining single break is replaced with your separator (a space by default). There is no semantic analysis, so do not use it on poetry, code or addresses where single breaks are meaningful.

What happens with three or more consecutive breaks?

They collapse to two line breaks, i.e. one blank line. "a\n\n\nb" becomes "a\n\nb".

Can the separator be empty?

Yes — any string works, including an empty one, which simply deletes in-paragraph breaks and joins the whole paragraph into a single line. The option itself must still be a string, otherwise the tool reports invalid-options. Note that `$` sequences such as `$&`, `$\`` or `$1` inside the separator are expanded as replacement patterns (a separator of `$&` leaves the line break in place); that is inherent to JavaScript string replacement and is not escaped here.

Is my text uploaded?

No. Everything runs in your browser through a pure function; there are no network requests and nothing is written to storage.

Keywords:stray line break removertext cleanup

Related tools