Convert line endings and clean whitespace
Convert CRLF to LF, strip trailing spaces, swap tabs and spaces, and remove a byte-order mark.
Runs in your browser. Your input is not uploaded.
Loading the tool…
What it does
Windows writes line endings as CRLF (\r\n); Linux and macOS use LF (\n). Mixed endings produce noisy diffs, ^M characters in shells and scripts that fail with bad interpreter.
This tool reports which endings the text contains, converts them, and fixes the other usual whitespace problems: trailing spaces, tabs versus spaces, a byte-order mark and a missing final newline.
How to use it
- Open the file. The counts of LF, CRLF and CR endings appear straight away. (Pasting works for whitespace clean-up, but browsers turn pasted line endings into LF, so open the file to see the real endings.)
- Choose the target line ending and any clean-ups.
- Download the result. Download keeps the exact bytes.
Things to watch for
- Copying to the clipboard can change line endings on some systems. Use Download when the exact bytes matter.
- Converting tabs to spaces expands every tab to a fixed width; it does not align to tab stops.
- A BOM at the start of a shell script stops the
#!line from working. Remove it.
Questions
- How do I convert CRLF to LF?
- Choose LF as the line ending and download the result. In Git,
git config core.autocrlf inputstops CRLF being committed. - What is a byte-order mark?
- The character U+FEFF at the start of a file. In UTF-8 it is three bytes,
EF BB BF. Some Windows editors add it; most Unix tools do not expect it. - Why does my script say bad interpreter?
- Usually the first line ends in CRLF, so the system looks for
/bin/bash\r. Convert to LF. - Should files end with a newline?
- POSIX defines a line as ending in a newline, and many tools expect one. Git shows “No newline at end of file” when it is missing.