Line Break Analyzer
Analyze line endings in text or files. Detect CRLF, LF, and CR line break types, count occurrences, and view line statistics including total lines, longest, shortest, and average line length.
Input
Output
Readme
What are line endings?
A line ending (also called a newline or end-of-line sequence) is a special character or pair of characters that marks where one line of text ends and the next begins. Three distinct conventions exist across operating systems: LF (\n, a single linefeed character), CRLF (\r\n, a carriage return followed by a linefeed), and CR (\r, a standalone carriage return).
The difference originates from early computing hardware. Typewriters required two physical steps to start a new line — moving the carriage back to the start (CR) and advancing the paper one line (LF). Unix systems adopted LF-only in the 1970s, while MS-DOS and later Windows kept the full CR+LF sequence. Classic Mac OS (before OS X) used CR alone, though modern macOS follows the Unix LF convention.
Mixed line endings are common in files that have been edited on multiple platforms, transferred between systems, or concatenated from different sources. They can cause subtle bugs in scripts, build tools, and version control systems.
Tool description
This tool analyzes text or a file and detects which line ending types are present. It counts each type individually — CRLF, LF, and CR — and reports the overall line ending style (including whether the file has mixed endings). It also provides basic line statistics: total line count, longest line, shortest line, and average line length.
Features
- Detects all three line ending types: CRLF (Windows), LF (Unix/macOS), and CR (classic Mac)
- Identifies mixed line endings and labels the dominant style
- Accepts both pasted text via a code editor and uploaded files of any text format
- Counts each line ending type independently with no double-counting
- Reports total lines, longest line, shortest line, and average line length
Use cases
- Debugging cross-platform build failures — scripts or configuration files with unexpected CRLF endings often break on Unix servers; use this tool to confirm line endings before deployment
- Code review preparation — verify that a file contributed from a Windows machine uses the project's expected LF convention before committing
- Text file auditing — quickly inspect log files, CSVs, or data exports to understand their structure before parsing them programmatically
How it works
CRLF sequences (\r\n) are detected and counted first using a regex match. The matched pairs are then removed from the string before separately counting standalone LF (\n) and CR (\r) characters. This prevents a single \r\n from being counted as both a CR and a LF. Line statistics are derived by splitting the original text on all three line ending patterns.