Line Break Analyzer

Detect and count CRLF, LF and CR line endings, and fix mixed files.

Line Break Analyzer

This tool detects the line endings in your text, counts each type, and reports the overall style.
Enter some text to view the line statistics, then use the Fix / Convert options to normalize it to a single line ending.


Load an example

0 characters
0 characters
Analysis Results
Detected Style
No input
CRLF (\r\n)
-
LF (\n)
-
CR (\r)
-
Total Lines
-
Shortest Line
-
Longest Line
-
Average Line Length
-
Blank Lines
-
Consecutive Break Runs
-
Indentation Summary
-
Mixed Endings at Lines
-
Fix & Convert Line Endings
The preferred default is suggested from the analysis, but you can choose any type.
Rewrites your input with only the chosen line ending and places it in the Output field.
Ready to analyze line endings.


Overview

The Line Break Analyzer examines the invisible line endings in your text or file and tells you exactly what it finds. Every line of text ends with one of three characters - CRLF (\r\n, Windows), LF (\n, Unix/macOS) or CR (\r, classic Mac) - and this tool detects, counts, and reports all of them.

It is built with plain vanilla JavaScript and runs fully in your browser, so your text never leaves your device. Paste text or upload a file and the analysis appears instantly: the detected line ending style, total, longest, shortest and average line lengths, blank lines, consecutive break runs, trailing newline, and - for mixed files - which lines use a foreign ending.

Best of all, it not only diagnoses but also fixes. The Fix & Convert panel rewrites your text using a single chosen line ending, so a Windows-style file can become Unix-style (or vice versa) in one click. Mixed endings are a common cause of subtle bugs in scripts and version control, and this tool makes them easy to spot and resolve.


How to Use the Tool

Step 1 - Enter your text: type or paste your text into the "Input" field, or click "Upload a file" to load a text file from your device. You can also click "Load an example" to test the tool with a ready-made sample.

Step 2 - View the analysis: the tool analyzes as you type, so the "Analysis Results" panel updates live. It shows the detected line ending style, the count of each break type (CRLF, LF, CR), total lines, longest, shortest and average line length, blank lines, consecutive break runs, whether the text ends with a newline, and where mixed endings appear.

Step 3 - Fix a file (optional): to convert all line endings to one style, choose a target in the "Fix & Convert Line Endings" panel - CRLF, LF or CR - and press "Convert to Output". The rewritten text appears in the "Output" field. A sensible default is pre-selected from the analysis, but you can override it.

Step 4 - Use the result: click "Copy" to put the fixed text on your clipboard or "Download" to save it as a file. "Clear & Reset" empties both fields and resets the output.

Tip: the derived statistics (longest, shortest, average, blank lines) are useful for spotting inconsistent formatting before you normalize a file.


Examples

Line endings are invisible characters, so each example below shows the text as you will type it and a summary of what the analyzer reports. Click "Try it" to load the real text (including its hidden line endings) and run the analysis.

1. A Windows-style file (CRLF)

Every line of this sample ends with \r\n. Clicking "Try it" loads the authentic text and reveals the counts.

Input
Review the monthly report
Fix the install script
Call the team before noon
Check the deployment logs
Analyzer report
Style: CRLF (\r\n, Windows)
CRLF: 3  LF: 0  CR: 0
Total lines: 4

2. A Unix-style file (LF)

This sample is a typical developer shell session where every line ends with \n only.

Input
npm install
npm run build
npm test
Deploy the package to staging
Analyzer report
Style: LF (\n, Unix/macOS)
CRLF: 0  LF: 3  CR: 0
Total lines: 4

3. Mixed line endings

Three lines use \r\n but line 2 uses a plain \n. The analyzer flags the mixed file and points to the foreign line.

Input
First paragraph with a CRLF ending
Second line uses a plain LF
Third line is back to CRLF
Forth line also CRLF
Analyzer report
Style: Mixed - dominant CRLF (\r\n, Windows)
CRLF: 2  LF: 1  CR: 0
Mixed endings at lines: 2

4. Blank lines and a trailing newline

This sample contains blank lines, a double and a triple break, and ends with a newline - all reported by the analysis.

Input
Heading

Body paragraph one


Body paragraph two
Analyzer report
Style: LF (\n, Unix/macOS)
Total lines: 6  Blank lines: 3
2 consecutive break runs (max 3 blank lines)
Ends with a line break: yes

Features & Options

Detects all three line ending types: counts CRLF (\r\n, Windows/MS-DOS), LF (\n, Unix/macOS) and CR (\r, classic Mac) separately. CRLF pairs are counted first and removed, so a single \r\n is never double-counted as both a CR and an LF.

Detected style label: reports the overall style - "CRLF (Windows)", "LF (Unix/macOS)", "CR (classic Mac)" or "Mixed line endings" - and names the dominant type when the file is mixed.

Line statistics: shows total lines, the longest line (with a preview of its text), the shortest line, the average line length, the number of blank lines, and how many consecutive line-break runs were found (with the longest run).

Trailing newline check: reports whether (and how) the text ends with a line break - a common requirement for POSIX-style text files that editors often miss.

Mixed-ending locations: in a mixed file, lists the line numbers where a non-dominant ending type appears (up to the first 10), so you can find the offending lines quickly.

Indentation summary: counts how many non-blank lines start with a tab, with spaces, or mix both - a quick way to catch inconsistent indentation before opening a file in an editor that expands tabs.

Fix & Convert line endings: the normalizer rewrites your input using a single chosen ending - CRLF, LF or CR - and places the result in the Output field. A sensible default is pre-selected from the analysis, but any type can be chosen.

Copy & Download: "Copy" puts the Output (the fixed text) on your clipboard and "Download" saves it as a text file. Character counters under both fields show the text length at all times.


FAQs

FAQ 1: What is the difference between CRLF, LF and CR?
Answer: They are the invisible characters that mark the end of a line. Windows and MS-DOS use \r\n (CRLF), Unix and macOS use \n (LF), and classic Mac OS used \r (CR) alone. The tool counts each type separately so you can see exactly which convention a file uses.

FAQ 2: Why do I care about mixed line endings?
Answer: Files edited on multiple platforms or concatenated from different sources often mix endings. This can cause subtle bugs in scripts, build tools and version control diffs. The tool detects a mixed file immediately and tells you where the odd endings are.

FAQ 3: How do I fix a file that has mixed line endings?
Answer: Use the "Fix & Convert Line Endings" panel: choose CRLF, LF or CR as your target and press "Convert to Output". Every line ending in the output is rewritten to that single type, then copy or download the result.

FAQ 4: Why is a CRLF not counted as both a CR and an LF?
Answer: The analyzer counts CRLF pairs first and removes them before counting standalone LF and CR characters. This prevents a single \r\n sequence from inflating both the CR and the LF totals.

FAQ 5: What counts as a "blank line"?
Answer: A line whose content is empty or only whitespace (spaces or tabs). Blank lines and consecutive line-break runs are reported so you can tidy up files that have excessive vertical spacing.

FAQ 6: Is my text uploaded anywhere?
Answer: No. The whole tool runs in your browser with plain JavaScript. Nothing you type, paste or upload ever leaves your device.

TextToolz

The Ultimate Text Tools

TextToolz works seamlessly to let you convert and design your text. It is fast, reliable and secure. Trusted by thousands of users.