LineBreaks

Convert line endings

One mode, one job: rewrite the bytes between lines and change nothing else. Every other option is off, deliberately — a conversion that also trimmed your lines would be impossible to review. The table below shows the exact bytes for every input form and every target.

Nothing but the bytes between lines changes.

3 lines · 34 characters · 6 wordsLF ×2
3 lines · 36 characters+2 characters

A UTF-8 file that begins with a byte-order mark and uses LF throughout — the state most files arrive in from a code editor.

The three targets

Which target to pick, and who expects it.
TargetBytesExpected by
LF 0A Unix, macOS, the web, JSON, Docker, most build tools
CRLF 0D 0A Windows editors, HTTP/1.1 headers (RFC 9112), CSV records (RFC 4180)
CR 0D Classic Mac OS through version 9, and some serial devices

Every input, every target, byte for byte

7 inputs — one for each of the 6 break forms the tool recognises, plus a file that mixes three of them. Each converted to each of the three targets, with the UTF-8 bytes before and after. This table is generated by calling the tool while the page is built, so it cannot describe a conversion the tool does not perform, and the single-form rows are derived from the splitter's own list of break kinds, so it cannot leave one out.

Both lines are alpha and beta except in the mixed row, which has four. The byte delta is the size change for the whole string.
Input Bytes in → LF→ CRLF→ CR
LF input
alpha␊beta
The common case: a file written on Unix or by a code editor.
61 6C 70 68 61 0A 62 65 74 61
10 bytes
61 6C 70 68 61 0A 62 65 74 61
10 bytes (+0) · unchanged
61 6C 70 68 61 0D 0A 62 65 74 61
11 bytes (+1)
61 6C 70 68 61 0D 62 65 74 61
10 bytes (+0)
CRLF input
alpha␍␊beta
A file written on Windows.
61 6C 70 68 61 0D 0A 62 65 74 61
11 bytes
61 6C 70 68 61 0A 62 65 74 61
10 bytes (-1)
61 6C 70 68 61 0D 0A 62 65 74 61
11 bytes (+0) · unchanged
61 6C 70 68 61 0D 62 65 74 61
10 bytes (-1)
CR input
alpha␍beta
Classic Mac OS, or a CRLF that lost its LF.
61 6C 70 68 61 0D 62 65 74 61
10 bytes
61 6C 70 68 61 0A 62 65 74 61
10 bytes (+0)
61 6C 70 68 61 0D 0A 62 65 74 61
11 bytes (+1)
61 6C 70 68 61 0D 62 65 74 61
10 bytes (+0) · unchanged
NEL input
alpha⟦NEL⟧beta
A mainframe export transcoded from EBCDIC.
61 6C 70 68 61 C2 85 62 65 74 61
11 bytes
61 6C 70 68 61 0A 62 65 74 61
10 bytes (-1)
61 6C 70 68 61 0D 0A 62 65 74 61
11 bytes (+0)
61 6C 70 68 61 0D 62 65 74 61
10 bytes (-1)
LS input
alpha⟦LS⟧beta
A soft break pasted out of a layout application.
61 6C 70 68 61 E2 80 A8 62 65 74 61
12 bytes
61 6C 70 68 61 0A 62 65 74 61
10 bytes (-2)
61 6C 70 68 61 0D 0A 62 65 74 61
11 bytes (-1)
61 6C 70 68 61 0D 62 65 74 61
10 bytes (-2)
PS input
alpha⟦PS⟧beta
A paragraph boundary pasted out of a layout application.
61 6C 70 68 61 E2 80 A9 62 65 74 61
12 bytes
61 6C 70 68 61 0A 62 65 74 61
10 bytes (-2)
61 6C 70 68 61 0D 0A 62 65 74 61
11 bytes (-1)
61 6C 70 68 61 0D 62 65 74 61
10 bytes (-2)
Mixed file
alpha␍␊beta␊gamma␍delta
Three different endings in four lines — the state a file reaches after two people edit it on two platforms.
61 6C 70 68 61 0D 0A 62 65 74 61 0A 67 61 6D 6D 61 0D 64 65 6C 74 61
23 bytes
61 6C 70 68 61 0A 62 65 74 61 0A 67 61 6D 6D 61 0A 64 65 6C 74 61
22 bytes (-1)
61 6C 70 68 61 0D 0A 62 65 74 61 0D 0A 67 61 6D 6D 61 0D 0A 64 65 6C 74 61
25 bytes (+2)
61 6C 70 68 61 0D 62 65 74 61 0D 67 61 6D 6D 61 0D 64 65 6C 74 61
22 bytes (-1)

The LS and PS rows are the ones to read twice. Each starts 2 bytes larger than the LF row, because U+2028 and U+2029 are three UTF-8 bytes each — E2 80 A8 and E2 80 A9 — where LF is one. Converting either to LF therefore shrinks the file by 2 bytes even though the number of lines is unchanged. Nobody expects an ending conversion to change the size by more than one byte per line, and this is why it can.

The mixed row is the one you will actually meet. Four lines separated by CRLF, LF and CR in that order — 61 6C 70 68 61 0D 0A 62 65 74 61 0A 67 61 6D 6D 61 0D 64 65 6C 74 61 — become uniform under every target. That is the operation you actually want after two people have edited a file on two platforms, and it is one that a search-and-replace cannot do in a single pass without creating \r\r\n somewhere along the way.

The round-trip check

Converting to CRLF and back to LF must give the same answer as converting straight to LF. Every sample above was run through both routes and compared: true. That property is not free — a converter that turned each LF into CRLF with a plain replacement would turn a CRLF file into \r\r\n per line, and the second conversion would then have real damage to work with. This tool splits on break kinds and re-emits them, so a CRLF is handled as one token and never as two characters that happen to be adjacent.

Reversibility stops at normalisation. Converting a mixed file to LF discards the information about which breaks were CRLF, and no later conversion can recover it. If you need the original, keep it — this is exactly the hazard git's own documentation flags under core.safecrlf, quoted on the CRLF vs LF page.

What CRLF costs

Multiplication, not measurement: 1 extra byte per line — computed from the table above, not assumed — times the number of lines. For a document that is nothing. For a 1,000,000-line log it is 1,000,000 bytes, about 977 KiB: real, and still the least interesting reason to prefer LF. Compatibility with the tools that have to read the file is the reason that matters.

Doing it from the command line

Worth knowing, because the browser round trip is awkward for a file you are already working with in a terminal. Every one of these does the same job as the tool above for the LF target:

# Git Bash / WSL — GNU tr and GNU sed
tr -d '\r' < input.txt > output.txt          # deletes every CR, including deliberate ones
sed -i 's/\r$//' input.txt                   # deletes only a CR at end of line

# PowerShell 7
(Get-Content -Raw input.txt) -replace "`r`n", "`n" | Set-Content -NoNewline output.txt

Note the difference between the first two. tr -d '\r' removes every carriage return in the file, which is fine for text and wrong for anything binary that slipped in. The sed form only removes one at end of line, which is what you almost always mean. Neither handles NEL or U+2028, which is the gap the tool above exists to fill — the full comparison of which mechanisms recognise which break characters is on the word-processor page.

Which sed, though. The two shell lines are the GNU ones Git Bash ships, and this page was built on Windows with nothing else to try them against. In particular -i is the flag whose spelling is worth checking before you paste that line into a shell somewhere else: run sed --help there first. Nothing on this site is a claim about a system it was not built on.

Checking your work

Do not trust the appearance of the result. Press Show invisible characters and read the badges: a uniform column of LF or CRLF means the conversion took, and a stray CR means it did not. The counter strip under the input does the same job in one line, which is the faster check on a long file.

Before you convert a whole file

How do I convert CRLF to LF?

Paste the file above. The tool opens in ending-conversion mode; choose LF and copy or download the result. Nothing but the bytes between lines changes — line content, spaces and tabs are all untouched, which is what separates this mode from the others here.

Does converting line endings change anything else in my file?

No. This mode does not trim lines, does not collapse spaces and does not remove blank lines; those options are off by default here for exactly that reason. The only bytes that differ between input and output are the ones that separate lines.

Is the conversion reversible?

Between LF, CRLF and CR, yes — converting to CRLF and back to LF returns the same result as converting straight to LF, for every sample below: true. It is not reversible in the other direction: once a mixed file has been normalised, nothing records which of its breaks were originally CRLF.

What happens to U+2028 and NEL?

They are converted too. Any character this tool recognises as a line break becomes the target ending, which is usually exactly what you want — a file with a stray U+2028 in it is a file that behaves differently in every program that opens it. Switch off Treat U+0085, U+2028 and U+2029 as line breaks to leave them in place.

How much bigger is a CRLF file?

One byte per line — a figure the conversion table below computes rather than asserts. On a 100,000-line file that is 100,000 bytes, about 98 KiB. Irrelevant for a document, occasionally relevant for logs.

Will it remove the byte-order mark?

Not in this mode. A BOM is not a line break, so ending conversion leaves it alone — you can see it as a badge in the reveal view. To remove it, switch on Delete zero-width characters, which strips U+FEFF along with U+200B.

Can I open a file directly, without pasting?

Yes. Use the Open .txt button to load a file from your machine and the .txt button to download the result. The file never leaves your browser — it is read with the browser's own file reader, transformed in memory and written back out by a download link.

If the endings were not the whole problem

  • the line break remover with every mode exposed — for everything this mode deliberately refuses to touch — blank lines, runs of spaces, the wrapping itself, and words a hyphen split across two lines.
  • CRLF vs LF — where the two-character line ending came from, and what git actually does to your files under each core.autocrlf setting.
  • Remove line breaks in Excel and CSV — why a CSV has two kinds of line break that look identical, and how to strip one without destroying the other.
  • Remove line breaks in Word documents — soft breaks, paragraph separators and the no-break spaces a word processor leaves in your clipboard.
  • Word Counter — the other half of the tidy-up job: word, character and reading-time counts once the text is one paragraph again.
  • Case Converter — text pasted out of a PDF often arrives SHOUTING as well as broken — this fixes the capitalisation under four style guides.