Convert CRLF to LF Line Endings
Convert Windows CRLF line endings to Unix LF format. Essential for shell scripts, Docker files, and cross-platform development workflows.
Detailed Explanation
CRLF to LF Conversion
Converting from CRLF (\r\n) to LF (\n) is one of the most common text normalization tasks in cross-platform development. While Windows traditionally uses CRLF, virtually all modern development tools, CI/CD systems, and deployment targets run on Linux where LF is the standard.
When You Need This Conversion
- Shell scripts: A bash script with CRLF endings produces
\r: command not founderrors on Linux. The carriage return (\r) becomes part of the command. - Docker: Files COPY'd into a Linux container retain their original line endings. CRLF in entrypoint scripts causes container startup failures.
- Git hooks: Hook scripts must use LF on all platforms for consistent behavior.
- Makefiles: While Make is more tolerant than shell, CRLF in recipe lines can cause subtle issues.
- .env files: Some parsers include \r in the value, causing key lookup failures.
Step-by-Step Conversion
- Paste your text into the Whitespace Visualizer.
- Verify the line endings — CRLF will show as green ←↵ markers.
- The Line Endings panel will confirm: "CRLF (N)" or "Mixed: ...".
- In the Clean section, toggle CRLF on (and optionally CR for any standalone carriage returns).
- Click Clean — all CRLF sequences are replaced with LF.
- Click Copy Cleaned to get the LF-normalized text.
Verification
After cleaning, the Line Endings panel should show only "LF (N)" with no CRLF or CR counts. The statistics panel should show 0 for both CR and CRLF.
Automating the Conversion
For project-wide conversion, consider:
.gitattributes:* text=auto eol=lf.editorconfig:end_of_line = lf- Prettier:
"endOfLine": "lf"in config
These tools prevent CRLF from being committed in the first place.
Use Case
A developer on Windows writes a deployment script that works locally but fails on the Linux CI server. They paste the script into the Whitespace Visualizer, see CRLF markers on every line, convert to LF, and the CI pipeline runs successfully.