1001Ferramentas
↩️ Utilities

Line Ending Detector (LF/CRLF/CR)

Detect whether a text uses LF (Unix), CRLF (Windows) or CR (classic Mac), and how many of each appear.

Finding out whether a file uses CRLF, LF or CR

Line endings never settled on a single standard. Windows ended a line with two characters, carriage return and line feed — CRLF. Unix, Linux and modern macOS use just the line feed, LF. And Mac up to version 9 used the carriage return alone, a bare CR, which still turns up in old files and in exports from legacy systems.

Paste the text and the page counts each kind separately, naming the dominant one. The count treats CRLF as a unit before looking for stray CR and LF, so a normal Windows file shows a high CRLF count with the other two at zero. When all three show up mixed, the file passed through different editors without normalisation — a situation that breaks shell scripts, confuses diffs and makes Git flag the whole file as modified.

Where this bites: a script with CRLF on a Linux server returns "bad interpreter: /bin/bash^M", because the carriage return becomes part of the interpreter name; a configuration file read line by line carries an invisible character at the end of every value; and diffs show changes on every line even though nobody touched the content. The permanent fix is combining normalisation in .gitattributes with the editor setting.

Frequently asked questions

I pasted text that came from Windows and no CRLF showed up. Why?
That is expected. When you paste into a text field the browser normalises line endings, and the original CR may never reach this page. For reliable file diagnosis use file document.txt or cat -A, which reveal control characters. The page is accurate when the text comes from a source that preserves them.
How do I convert from CRLF to LF?
In a terminal, dos2unix file, or sed -i 's/\r$//' file. In VS Code, the CRLF/LF indicator in the bottom right switches with one click. For a whole repository, set up .gitattributes and run git add --renormalize . once.
Does this affect character counts?
It does. Each line of a CRLF file takes one byte more than the same line in LF. Across a large file the difference shows in the size, and in a field with a character limit — a description, a message — the text can overflow because of invisible carriage returns.

Related Tools