Opened a text file made on a Mac or Linux in an old Windows program and found everything on one line? Or opened a Windows file elsewhere and saw ^M at the end of every line? It looks like an encoding problem, but the cause is how line breaks are stored.
A line break is a character too
You can’t see it, but every line break is stored as an invisible character meaning “start a new line”. Operating systems disagree about which one:
| Style | Stored characters | Mainly used by |
|---|---|---|
| CRLF | CR + LF (two characters) | Windows |
| LF | LF (one character) | macOS, Linux, most web and programming tools |
| CR | CR (one character) | Very old Macs (rare today) |
The names come from typewriters: CR is “carriage return” (back to the start of the line), LF is “line feed” (down one line).
Typical symptoms
| Symptom | Cause |
|---|---|
| Everything appears on one line | An LF file opened in an old Windows program that only understands CRLF |
^M or \r at the end of lines |
A CRLF file opened in a Linux tool or some editors |
| Blank lines doubled | A conversion was applied twice, or a program treats CR and LF as separate breaks |
| Git warns “LF will be replaced by CRLF” | The repository and your computer use different settings |
Since the October 2018 update of Windows 10, Notepad displays LF files correctly, so problems today mostly come from older programs and in-house systems.
Checking which style a file uses
- Windows Notepad: the status bar at the bottom right shows
Windows (CRLF)orUnix (LF). - VS Code: the bottom right shows
CRLForLF; click it to switch. - Notepad++: Edit → EOL Conversion shows and changes it.
Choosing line endings when converting
Converters on this site that produce text (for example DOCX to TXT, EPUB to TXT, PDF to TXT and HTML to TXT) let you choose under Options → Line endings.
| If the file will be used… | Choose |
|---|---|
| For general use, on Mac, phones or the web | LF (default) |
| By old Windows programs or in-house systems | CRLF |
The CSV converters default to CRLF for compatibility with Excel.
To change the line endings of a text file you already have, use the text encoding converter and pick “Windows (CRLF)” or “Mac and Linux (LF)” under Options → Line endings. You can change the encoding at the same time.
Summary
Merged lines or ^M are a line ending (CRLF/LF) issue, not a character encoding one. Check the bottom-right corner of Notepad or VS Code and save in the style the receiving system expects. If characters are garbled instead, see text encoding explained.