Smart Apps Pro

Line Endings Explained: LF, CRLF and Why They Matter

Why text files from different systems sometimes look wrong, what line endings are, and how to keep your files tidy.

Every time you press Enter in a text file, an invisible character or two is stored to mark the end of the line. Different systems use different ones, and that can cause small annoyances.

The two styles

Name Characters Used by
LF (line feed) one character Linux, macOS, Android
CRLF (carriage return + line feed) two characters Windows

The names come from typewriters: the carriage return moved the carriage back to the start of the line, and the line feed moved the paper up.

When it causes problems

  • One long line: an old file may show all its text on one line if the editor doesn't understand the line endings.
  • Odd symbols: some tools show CR as a visible character such as ^M.
  • Scripts that won't run: a script saved with Windows endings may fail on Linux.
  • Messy comparisons: tools that compare files may show every line as changed.

How to avoid it

  1. Be consistent within a project or set of files.
  2. Use a modern editor that handles both.
  3. Choose one style and stick with it, LF being the most widely compatible choice for code.
  4. Check before sharing code or scripts with people on other systems.

Editing on Android

Android uses LF. When you edit files on your phone that came from a Windows computer, they may use CRLF. A good editor opens them correctly. For code files, it's worth checking the endings.

Everyday notes

For normal notes, you rarely need to think about this. The problem mostly appears when files move between systems or are used by programs.

A quick test

If a file appears as a single long line, or you see odd symbols at the end of lines, line endings are a likely cause.

Keep it simple

A lightweight editor that opens files quickly and shows text clearly is often enough for handling everyday plain-text files, including those from other systems.

Get Notepad+ Text Editor →

Notepad+ Text Editor app icon

Notepad+ Text Editor

A fast, advanced text editor for notes and code, with emoji support

Get the app

More about Notepad+ Text Editor