Overview
Introduction
Text pasted from different sources, a Windows text editor, a Unix terminal, or an old export, often mixes line-ending styles and picks up excessive blank lines.
Cleaning that up by hand, especially finding every stray carriage return, is tedious and error-prone.
What Is Line Break Normalizer?
A line break normalizer that converts CRLF and lone CR line endings to a plain LF, and collapses any run of three or more consecutive blank lines down to a single blank line.
It runs entirely client-side as part of this site's String Tools collection, so nothing you paste is ever uploaded to a server.
How Line Break Normalizer Works
The tool first replaces every CRLF pair and lone CR with a plain LF, then applies a second pass that collapses any sequence of three or more consecutive newlines down to exactly two, which leaves a single blank line between blocks.
The transformation happens synchronously in JavaScript the moment you type, with no network round trip involved.
When To Use Line Break Normalizer
Use it before diffing or version-controlling pasted text, cleaning up a document exported from an older tool, or tidying excessive spacing before publishing.
It's a fast way to get the answer without opening a code editor, a REPL, or writing a one-off script just to check.
Often used alongside Line Break Remover, Empty Line Remover and Paragraph Spacing Fixer.
Features
Advantages
- Fixes two common sources of messy pasted text in a single pass.
- Leaves intentional single blank lines between paragraphs untouched.
Limitations
- Doesn't trim leading or trailing blank lines from the whole document; pair it with the Paragraph Spacing Fixer for that.
Examples
Best Practices & Notes
Best Practices
- Run this tool on text pasted from Windows sources before committing it to a Unix-based version control system to avoid CRLF-related diff noise.
Developer Notes
Line endings are normalized with `input.replace(/\r\n|\r/g, "\n")`, then blank-line runs are collapsed with `.replace(/\n{3,}/g, "\n\n")`, which targets three-or-more newline sequences specifically so a single intentional blank line (two newlines) is left alone.
Line Break Normalizer Use Cases
- Cleaning up text pasted from a Windows source before committing it to git
- Tidying excessive blank lines from a document export
- Standardizing line endings before running a diff or text comparison
Common Mistakes
- Expecting leading or trailing blank lines at the very start or end of the document to be trimmed; this tool only targets line-ending style and mid-document blank-line runs.
Tips
- Combine this with the Paragraph Spacing Fixer tool if you also want leading and trailing blank lines trimmed from the whole document.