02.2Line endings

Line ending converter

See how many lines end in CRLF, LF or a lone CR, convert them all to one style and decide whether the file ends with a newline. Drop several files and get them back, or as a ZIP.

people.csv

or drop files on this box

Detected

people.csv
LF (\n)
1
CRLF (\r\n)
3
CR (\r)
1
Style
mixed
Final newline
no
Lines
6

Options

Convert line endings to
Final newline
1Δid,name,city↵
2Δ1,Ada,London↵
32,Grace,Arlington↵
4Δ3,Linus,Helsinki↵
5Δ4,Margaret,Boston↵
6Δ5,Ken,Murray·Hill↵

Done: Converted 4 line endings and added a final newline. Result: LF ×6.

CRLF, LF and CR

Unix, Linux and macOS end lines with a line feed (LF, \n). Windows uses a carriage return and a line feed (CRLF, \r\n). A lone carriage return (CR, \r) comes from classic Mac OS and some old exports. Most editors cope with any of them, but shell scripts with CRLF fail with $'\r': command not found, diffs light up on every line, and Git warns that “LF will be replaced by CRLF”.

  • Convert to rewrites every line ending to one style. Keep leaves them alone, so you can fix only the final newline.
  • Always end with one adds a line break after the last line if it is missing. POSIX tools expect it, and Git shows “No newline at end of file” without it.
  • Remove drops the line breaks at the very end of the file, including empty lines there.

Files keep their name and encoding, including a UTF-8 byte order mark. Text you paste keeps its line endings too; once you edit it in the box, the edited text uses the style it had before.

Questions

Which line ending should I use?

LF for almost everything, including files in Git repositories. Use CRLF for Windows batch files and anything a Windows-only tool reads. A .gitattributes line such as * text=auto eol=lf keeps it that way.

Why does a file have mixed line endings?

Usually because it was edited on different systems or pasted together from several sources. The Original view marks the lines that differ from the most common ending.

Are my files uploaded?

No. Files are read and converted in your browser and saved straight back to your device.