Line Break Normalizer

Normalizes inconsistent line endings by converting Windows-style CRLF and old Mac-style lone CR to plain LF, and collapses runs of three or more consecutive blank lines down to a single blank line, cleaning up messy pasted text. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-23

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.

Features

Advantages

  • Fixes two common sources of messy pasted text in a single pass.
  • Leaves intentional single blank lines between paragraphs untouched.
  • Normalizes the line endings before collapsing blank runs, so a CRLF document's blank lines are detected correctly instead of being missed entirely.

Limitations

  • Doesn't trim leading or trailing blank lines from the whole document; pair it with the Paragraph Spacing Fixer for that.
  • Collapses three or more newlines to exactly two, so a deliberately wider gap between sections cannot be preserved.

Examples

Collapsing excess blank lines

Input

paragraph one



paragraph two

Output

paragraph one

paragraph two

The three consecutive blank lines between the paragraphs are collapsed down to a single blank line.

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.
  • Run it on anything pasted out of a word processor or email client, which are the usual sources of mixed line endings.
  • Apply it before committing text files, since mixed endings otherwise surface as whole-file changes in a diff.

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.
  • Assuming it converts towards CRLF for Windows use; normalization always goes the other way, to plain LF.

Tips

  • Combine this with the Paragraph Spacing Fixer tool if you also want leading and trailing blank lines trimmed from the whole document.
  • A file that looks identical after running this may still have been changed, because line-ending characters are invisible in most editors.

References

Frequently Asked Questions