Line Ending & Tab Converter

Convert line endings (CRLF and LF) and tabs to spaces.

Line endings
Final newline
0 words · 0 charactersNot uploaded

Line endings

Operating systems mark the end of a line differently:

  • LF (\n): Linux, macOS, most code repositories and web servers;
  • CRLF (\r\n): Windows, many Windows apps, and protocols like HTTP and SMTP;
  • CR (\r): classic Mac OS before 2001.

Mixed or unexpected endings cause noisy diffs, failing shell scripts (“/bin/bash^M: bad interpreter”), CSV import problems and checksum mismatches. Choose the target ending and the download keeps exactly those bytes.

Browsers convert line endings to LF inside text boxes, so to detect a file’s existing endings, load it with Open: the report under the result then counts CRLF, LF and CR in the original.

Tabs, trailing spaces and the final newline

  • Tabs → spaces expands each tab to the next tab stop (not a fixed number of spaces), so alignment is preserved.
  • Leading spaces → tabs converts indentation only.
  • Trim trailing whitespace removes invisible spaces at line ends that show up as changes in code review.
  • Final newline: POSIX tools expect text files to end with a newline; some linters require it, others forbid a blank last line.

Worked example

Here is what the Line Ending & Tab Converter returns for its built-in example. Settings used: Line endings: LF (Unix, macOS); Tabs: Keep; Trim trailing whitespace: on. Click Try an example in the tool above to load it, then change it as you like.

Input
function hello() {
	console.log("hi");   
        return true;
}
Output
function hello() {
	console.log("hi");
        return true;
}

Related tools: Text Wrapper, Remove Extra Spaces.

Questions

How do I convert CRLF to LF?

Choose LF as the line ending and download the result, or open the file with the Open button first to see what endings it has.

Why does my script fail with ^M?

The file has Windows CRLF line endings. Convert it to LF.

Last reviewed · How Textkiln tools work