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.
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.Put these concepts into practice
Use our dedicated, browser-based utilities to format, clean, and generate your files instantly.
Ready to Create Plain Text Files?
Open our online notepad and TXT File Maker to write, format, and download .txt files.
More Webmaster & Plain Text Tools
Apply these best practices using our dedicated client-side utilities.
TXT File Maker
Online notepad & text file creator with UTF-8, ANSI & CRLF/LF line endings.
Batch TXT Generator
Generate hundreds of customized text files with variables and ZIP export.
Text Case Converter
Transform strings into UPPERCASE, lowercase, Title Case, camelCase & snake_case.
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.
The Complete Guide to Plain Text (.txt) Files: Architecture, Encodings, and Best Practices
Character Encodings Explained: UTF-8, UTF-16, ASCII, and Windows-1252
How to Generate TXT Files in Batch for Testing, Automation, and Data Workflows
Frequently Asked Questions
Find quick answers to common questions about plain text files, encodings, and online tools.