Skip to main content

Detect CRLF vs LF Line Endings Detect and count line ending types (CRLF, LF, CR) in text files.

Line Ending Detector illustration
🔄

Line Ending Detector

Detect and count line ending types (CRLF, LF, CR) in text files.

1

Paste text

Paste the text content you want to analyze.

2

Analyze

Click Analyze to detect and count line ending types.

3

View results

See counts for CRLF, LF, and CR with recommendations.

Loading tool...

What Is Line Ending Detector?

Line Ending Detector analyzes text to identify and count the types of line endings used. Different operating systems use different line ending conventions: Windows uses CRLF (\r\n), Unix/Linux/macOS uses LF (\n), and classic Mac OS used CR (\r). Mixed line endings can cause issues in version control, text editors, and scripts. This tool counts each type, identifies the dominant convention, detects mixed endings, and provides a recommendation for normalization.

Why Use Line Ending Detector?

  • Counts all three line ending types: CRLF, LF, and CR.
  • Detects mixed line endings that can cause compatibility issues.
  • Identifies the dominant line ending convention.
  • Provides normalization recommendations.

Common Use Cases

Git Issues

Diagnose line ending conflicts in Git repositories, especially cross-platform projects.

Script Debugging

Debug shell scripts that fail on Windows or batch scripts that fail on Linux due to line endings.

Code Review

Verify consistent line endings across source code files.

File Comparison

Understand why files appear different in diff tools due to line ending differences.

Technical Guide

The detector scans the input text character by character. It recognizes three line ending patterns:

- CRLF (\r\n): Two-character sequence, counted as one line ending. The \n after \r is consumed to prevent double-counting.
- LF (\n): Single character, counted only when not preceded by \r.
- CR (\r): Single character, counted only when not followed by \n.

Mixed endings are flagged when more than one type is present. The dominant type is determined by comparing counts. The total line count is the sum of all line endings plus one (for the last line).

Recommendation logic: If mixed endings are detected, the tool recommends normalizing to the more common type (CRLF for Windows-heavy codebases, LF for Unix-heavy codebases).

Tips & Best Practices

  • 1
    Mixed line endings are a common source of Git diff noise — normalize before committing.
  • 2
    Most modern editors (VS Code, Sublime) can convert line endings via status bar settings.
  • 3
    Git's core.autocrlf setting can help manage line endings across platforms.
  • 4
    Unix/macOS uses LF, Windows uses CRLF — choose one standard for your project.

Related Tools

Frequently Asked Questions

Q What is the difference between CRLF and LF?
CRLF (\r\n) uses two characters and is the Windows standard. LF (\n) uses one character and is the Unix/macOS standard.
Q Why do mixed line endings cause problems?
Mixed endings can cause: Git showing entire files as changed, shell scripts failing, and inconsistent behavior across platforms.
Q How can I fix mixed line endings?
Most text editors have line ending conversion options. In VS Code, click the line ending indicator in the status bar.
Q What are CR line endings?
CR-only line endings were used by classic Mac OS (pre-OS X). They are rare in modern files.
Q Does Git handle line endings?
Git has settings (core.autocrlf, .gitattributes) to manage line ending conversion on checkout and commit.

About This Tool

Line Ending Detector is a free online tool by FreeToolkit.ai. All processing happens directly in your browser — your data never leaves your device. No registration or installation required.