Home/Guides/CRLF vs LF: Understanding Line Endings Across Windows, macOS, and Linux
Back to Knowledge Base
DevOps & Systems

CRLF vs LF: Understanding Line Endings Across Windows, macOS, and Linux

Carriage Return vs Line Feed explained: how line terminators work, why Git line-ending warnings occur, and how to normalize text files across Windows, macOS, and Linux.

TxtCraft Team
Editorial Team
•2026-08-21•6 min read

The Mechanical Origins of Line Endings

The discrepancy between operating system line endings dates back to electro-mechanical teleprinters and typewriters in the mid-20th century:

- Carriage Return (CR, 0x0D): Mechanically rolled the typewriter carriage back to the extreme left margin without advancing the paper down. - Line Feed (LF, 0x0A): Rotated the typewriter platen roller to advance the paper one line downwards without moving the carriage.

Because physical typewriters required a brief millisecond delay to roll the heavy metal carriage back to the left, two separate signals were transmitted: CR followed by LF.


Modern Operating System Standards

1. Windows OS (CRLF - \r\n): Microsoft MS-DOS and Windows preserved the two-byte CRLF convention for compatibility with CP/M teleprinters. 2. Unix & Linux (LF - \n): Bell Labs engineers designed Unix to be lean and memory-efficient, standardizing on a single byte (LF) for end-of-line. 3. macOS (LF - \n): Apple Mac OS 9 and earlier used CR. When Apple transitioned to Darwin / BSD Unix in Mac OS X, macOS adopted standard LF.


How to Convert Between CRLF and LF

Using TxtCraft: 1. Open our online Line Tools & Sorter to deduplicate, sort, and strip trailing whitespace. 2. Open the TXT File Maker and use the Line Endings selector in the bottom status bar to toggle between CRLF (Windows) and LF (Unix/macOS). 3. If you need to verify what changed between revisions, check the differences with the Text Diff Checker. 4. Download your normalized file with a single click.

Ready to Create Plain Text Files?

Open our online notepad and TXT File Maker to write, format, and download .txt files.

Open TXT File Maker →

More Webmaster & Plain Text Tools

Apply these best practices using our dedicated client-side utilities.

Related Plain Text Templates

Download standardized templates implementing these guidelines.

More Technical Guides & Tutorials

Deepen your understanding of file systems, data encoding, and DevOps automation.

Frequently Asked Questions

Find quick answers to common questions about plain text files, encodings, and online tools.

CRLF stands for Carriage Return (\r, ASCII 13) followed by Line Feed (\n, ASCII 10), used primarily by Windows. LF is just Line Feed (\n), used by Linux, macOS, and Unix-like operating systems.