Line Ending Converter

Find and convert line endings: LF (Linux, macOS, Git), CRLF (Windows) and CR (classic Mac OS). Paste text or drop files; only the line-break bytes change, so the encoding and BOM stay exactly as they were.

Converter Text & Encoding Updated Oct 15, 2026
How to Use
  1. Paste text, or drop one or more files on the drop zone (or click it to choose files). Files are read as raw bytes in your browser and never uploaded.
  2. Read what was found: how many CRLF, LF and lone CR line breaks, whether they are mixed (the odd ones out are listed by line number and highlighted in the line map), the encoding, and whether the last line ends with a line break.
  3. Pick the target: LF for Linux, macOS, Git and shell scripts, CRLF for Windows batch files and Windows-only tools, or CR for classic Mac OS.
  4. If you need to, add a missing line break at the end of the file or remove the last one.
  5. Press Download: each file keeps its original name (several files can also be saved as one ZIP). Show Work lists exactly what changed and how many bytes it saved or added.
Input
Typed text always uses LF (browsers store text-box line breaks that way). Pasting into an empty box keeps the clipboard’s own line breaks; for an exact byte-level result, use a file.
Drop files here, or click to choose
Any size, several at once. Read as bytes in your browser; nothing is uploaded.
Presets
Line Breaks
CRLF
—
LF
—
Lone CR
—
Size change
—

Worked Example

A three-line Windows file: echo one, echo two, echo three, each ending in CRLF. The text is 8 + 8 + 10 = 26 bytes and the three line breaks are 3 × 2 = 6 bytes, so the file is 32 bytes. The end of the first line in hex is 6F 6E 65 0D 0A (“one”, CR, LF).

Converted to LF: each 0D 0A becomes 0A, saving 1 byte per line break: 32 − 3 = 29 bytes. The first line now ends 6F 6E 65 0A; every other byte is the same. Converting the result to LF again changes nothing.

The same file in UTF-16 LE (as Windows PowerShell 5.1 writes it) is 2 bytes of BOM (FF FE) plus 32 characters × 2 bytes = 66 bytes. Here a CRLF is 0D 00 0A 00 and an LF is 0A 00, so each conversion saves 2 bytes: 66 − 3 × 2 = 60 bytes, still UTF-16 LE with its BOM.

The common mistake: deleting every 0D byte. That is what tr -d '\r' does, and it is fine for UTF-8, but in UTF-16 it leaves 00 0A 00 where 0D 00 0A 00 was: one byte short, so the next line is read one byte out of step: echo two comes out as “攀挀栀漀 琀眀漀”, and so does every second line after it. A line break has to be converted as whole code units, which is what this tool does.

Show Work

Paste some text, drop a file or pick a preset to see exactly what changes.

Line-Break Bytes and Size Change

Carriage return (CR)
CR = 0x0D = 13 = \r
ASCII: back to the first position on the same line
Line feed (LF)
LF = 0x0A = 10 = \n
ASCII: down to the next line
Bytes per line break
CRLF = 2u   LF = CR = u
u = bytes per code unit: 1 (ASCII, UTF-8, Windows-1252), 2 (UTF-16), 4 (UTF-32)
UTF-16 byte order
LE: CRLF = 0D 00 0A 00   BE: 00 0D 00 0A
Detected from the BOM: FF FE = little-endian, FE FF = big-endian
Size change to LF or CR
Δ = −u × nCRLF
LF ↔ CR swaps one unit for one, so only CRLFs change the size
Size change to CRLF
Δ = +u × (nLF + nCR)
Each single-unit line break gains one unit
Lines
lines = breaks + (last line unterminated ? 1 : 0)
“a\nb” is 2 lines with 1 break; “a\nb\n” is 2 lines with 2

From Teletypes to Git: Why There Are Three Line Endings

The two characters come from printing terminals. In ASCII, as written down for network use in RFC 20 (1969), carriage return moves the printing position back to the first position on the same line and line feed moves it to the next line. On a Teletype such as the Model 33, CR physically sent the print carriage back to the left margin and LF advanced the paper. Starting a new line took both, and CR went first because it was the slow one: a character sent straight after it could be printed as a smudge while the carriage was still moving, so the LF that followed covered the gap.

Early systems wrote text the way the terminal needed it. DEC minicomputers and CP/M stored CR LF, MS-DOS (1981) kept CP/M’s convention for compatibility, and Windows inherited it from DOS. Multics, begun in 1964, chose LF alone and let the device driver add whatever a particular terminal needed; Unix followed Multics, and Linux and macOS follow Unix. The Apple II and classic Mac OS used CR alone, until Mac OS X, built on Unix, switched the Mac to LF.

The split still causes trouble. A shell script saved with CRLF fails with bad interpreter or $'\r': command not found, because Bash reads the CR as part of the line. Git can convert line endings on commit and checkout (core.autocrlf, or per-file rules with the text and eol attributes in .gitattributes), and a file with a mix of CRLF and LF cannot be restored exactly once Git has normalised it. Windows Notepad only started displaying LF and CR files properly in Windows 10 version 1809 (2018). Some standards fix CRLF for good: HTTP/1.1 (RFC 9112) and Internet mail (RFC 5322) define CRLF as the line terminator.

Unicode lists a few more newline characters — NEL (U+0085), line separator (U+2028) and paragraph separator (U+2029) — in its Newline Guidelines (Unicode Standard, section 5.8). They are rare in files; this tool leaves them alone, as dos2unix does, and converts only CR, LF and CRLF.

About This Tool

This is dos2unix and unix2dos in a web page. It counts every CRLF, LF and lone CR, names the line numbers of the odd ones out when a file mixes them, shows the encoding and whether the last line is terminated, then converts to LF, CRLF or CR and can add or remove the final line break. A byte diagram shows what each kind of line break becomes, and Show Work gives the exact size change.

It differs from converting text in an editor in one way that matters: it never decodes and re-encodes your file. Only the line-break code units are rewritten; every other byte, including a UTF-8 or UTF-16 BOM, is copied as it was, and UTF-16 and UTF-32 files are handled two or four bytes at a time. Several files can be converted at once, and large files are processed in 4 MB pieces, with a CR at the end of one piece correctly joined to an LF at the start of the next.

Everything runs in your browser; no text or file is uploaded or stored.

Related tools: BOM Adder / Remover, Text Encoding Converter, and Text Cleaner.

Frequently Asked Questions

What is the difference between CRLF and LF?

They are two ways to end a line of text. CRLF is two bytes, 0D 0A (carriage return, then line feed), and is the Windows convention. LF is the single byte 0A, used by Linux, macOS and other Unix-like systems. A 1,000-line file converted from CRLF to LF becomes exactly 1,000 bytes smaller and nothing else in it changes. CR alone (0D) was the line ending of classic Mac OS up to version 9.

Should I use LF or CRLF?

Use LF for source code, web files, shell scripts and anything kept in Git or run on Linux or macOS. Use CRLF for Windows batch files (.bat, .cmd) and for older Windows programs that expect it. Network protocols fix their own: HTTP/1.1 headers (RFC 9112) and email (RFC 5322) are defined with CRLF. Windows Notepad has displayed LF files correctly since Windows 10 version 1809 (2018), so LF is rarely a problem on Windows any more.

How do I stop Git changing my line endings?

Commit a .gitattributes file. * text=auto lets Git find text files and store them with LF in the repository; *.sh text eol=lf keeps shell scripts LF in every checkout, and *.bat text eol=crlf keeps batch files CRLF. Without these, each person’s core.autocrlf decides: true converts LF to CRLF on checkout and back to LF on commit, input only converts CRLF to LF on commit. After adding the file, git add --renormalize . fixes files already committed with the wrong endings.

Why does my script fail with “\r: command not found” or “bad interpreter”?

The script was saved with CRLF line endings, usually by a Windows editor. Bash treats the CR as part of each line: the first line becomes #!/bin/bash plus an invisible CR, so the system looks for a program literally named “bash\r” and reports /bin/bash^M: bad interpreter: No such file or directory, and other lines fail with $'\r': command not found. Convert the file to LF and it runs.

Does converting change the encoding, the BOM or anything else?

No. The tool works on the file’s bytes: it rewrites only line-break code units and copies every other byte unchanged, so a UTF-8 BOM stays, Windows-1252 accents stay, and a UTF-16 file stays UTF-16 with its BOM (there a line break is 0D 00 0A 00, and it is converted as a whole). In UTF-8 the bytes 0D and 0A never occur inside a multi-byte character, so nothing else can be hit. By contrast, dos2unix by default rewrites UTF-16 files as UTF-8 unless you give it --keep-utf16.

How do I use the Line Ending Converter?

Just type or paste your value. The answer shows up right away — there is no button to press. Change anything and it updates by itself.

Do I need to install or sign up for anything?

Not at all — it runs in the browser with nothing to install and no account. After it loads once, it even works without an internet connection.

Is my information private?

Yes. Everything happens in your browser. Nothing you type is sent to a server or saved anywhere.

Common Use Cases

Shell scripts edited on Windows

A deploy.sh saved in a Windows editor fails on the server with “bad interpreter”. Converting its 3 CRLF lines to LF and adding the missing final line break takes it from 75 to 73 bytes, and it runs.

Mixed endings after copy-paste

A config file that is LF except for lines 2 and 5, pasted in from a Windows document. The tool lists those two lines, and converting them shrinks the file by 2 bytes — not every line.

Diffs where every line changed

When an editor flips a 300-line file to CRLF, Git shows all 300 lines as changed. Converting back to LF leaves only the real edits in the diff.

Old Mac text files

A file from Mac OS 9 or earlier uses CR only, so many programs show it as one long line. Converting its 250 CRs to LF gives 250 lines back at exactly the same size.

UTF-16 output from Windows PowerShell

Windows PowerShell 5.1 writes redirected output as UTF-16 LE with a BOM. Converted here it stays UTF-16 LE; each CRLF (4 bytes) becomes LF (2 bytes), so 1,000 lines save 2,000 bytes.

Large exports

A 100 MB CSV export with 1.2 million CRLF rows becomes 1.2 million bytes smaller as LF. Files are converted in 4 MB pieces, so the page stays responsive.

Last updated: