Newline Normalizer

Detect and convert line endings between LF, CRLF and CR.

  • Runs locally in your browser
  • No upload required

Try it

CRLF
1
LF
1
CR
1
Mixed
yes

Supported formats

Input
text, select
Output
number, text

Privacy

Runs entirely in your browser. Your input is never uploaded, stored, or sent to a third party.

Processing
In your browser
Privacy level
Browser only

Mixed endings (1 CRLF, 1 LF, 1 CR); converted to LF.

How it works

  • Counted CRLF, bare LF and bare CR sequences.
  • Normalised every ending to LF first, then to the requested style.
  • The last line without a trailing newline is left unchanged; only existing line breaks are converted.
  • CRLF is the convention on Windows, LF on Unix and in Git's default repository blob form.

Methodology

  1. Count CRLF, bare LF and bare CR sequences.
  2. Normalise the text to LF, then re-apply the requested ending.
  3. Report the original counts, whether they were mixed, and the converted text.

Usage

  1. Paste the text with the line endings to inspect.
  2. Choose the target ending (LF, CRLF or CR).
  3. Read the detected counts and copy the converted text.

Examples

These are examples, not current values: they use fixed inputs, while the interactive tool computes live results in your browser.

Mixed endings to LF

jsonSelect to copy
{
  "text": "a\r\nb\nc\rd",
  "style": "lf"
}

LF to CRLF

jsonSelect to copy
{
  "text": "one\ntwo\n",
  "style": "crlf"
}

No line breaks

jsonSelect to copy
{
  "text": "single line",
  "style": "lf"
}

Limitations

Why line endings get mixed

Different editors and operating systems use different line terminators: LF (`\n`) on Unix, CRLF (`\r\n`) on Windows and a bare CR (`\r`) on classic Mac OS. When a file is edited across systems without normalisation, it can end up containing several kinds at once.

Mixed endings produce whole-file diffs and can break shell scripts (a `\r` at the end of `#!/bin/sh` makes the interpreter unfindable). Normalising to a single style before committing avoids both.

Frequently asked questions

Which line ending should I use?
Use LF in the repository and let `.gitattributes` (`* text=auto`) handle checkouts on Windows, unless your project standard says otherwise.
What is a mixed file?
A file that contains more than one kind of line ending; that is what most commonly causes noisy diffs and is what this tool reports as mixed.

Sources

  1. The Open Group Base Specifications: Definitions — The Open Group
  2. Git: gitattributes text and eol — Git