Line ending converter
What is a Line Ending Converter?
Text files mark the end of each line with invisible control characters, and different operating systems use different ones. Mixing them causes shell scripts that fail with strange errors, Git diffs where every line looks changed, and stray ^M characters in editors. This tool detects which line endings a text uses and converts it to the style you need.
How to use it
- Paste the text.
- See the detected line ending style.
- Convert to LF, CRLF or CR and copy the result.
The three styles
- LF (line feed,
\n, byte 0x0A): Linux, macOS and most of the web. - CRLF (carriage return plus line feed,
\r\n, bytes 0x0D 0x0A): Windows, and required by HTTP headers, SMTP and CSV (RFC 4180). - CR (
\r, byte 0x0D): classic Mac OS before OS X; rare today.
Typical problems and fixes
- Bash script fails with
/bin/bash^M: bad interpreter: the script has CRLF endings. Convert it to LF. - Every line changed in Git: an editor converted the file's endings. Add a
.gitattributesfile with* text=auto eol=lfto normalise the repository. - Dockerfiles and YAML written on Windows can break Linux containers when they contain CRLF in entrypoint scripts.
Git settings
core.autocrlf=trueon Windows converts LF to CRLF on checkout and back to LF on commit.core.autocrlf=inputon macOS and Linux converts CRLF to LF on commit only.- A
.gitattributesfile overrides personal settings and keeps the whole team consistent.
Most modern editors, including VS Code, show and change the line ending style in the status bar.
Frequently Asked Questions
What is the difference between LF and CRLF?
LF is a single line feed character used by Linux and macOS. CRLF adds a carriage return before it and is used by Windows.
What does ^M mean in my file?
It is a visible carriage return, meaning the file has Windows CRLF line endings being viewed on a Unix system.
Why does my shell script fail with bad interpreter?
The script probably has CRLF line endings. Convert it to LF.
How do I stop line ending changes in Git?
Add a .gitattributes file, for example with * text=auto eol=lf, so Git normalises line endings for everyone.