How to convert CRLF to LF on Mac
You can do this with Note My. It shows you which line endings are actually in the file — including a file carrying both at once — and converts them cleanly.
A file looks fine on screen and behaves badly everywhere else. A shell script refuses to run and blames a line you can see is correct. A diff marks every line as changed when you edited one. The cause is usually the same: the file uses a line-ending convention something downstream did not expect, or it uses two of them at once.
This guide covers how to see which line endings a file actually contains in Note My, how to convert the whole document, and what happens to that choice the next time you save.
Three line endings, and which system produced which
A line ending is one or two invisible control characters at the end of every line. Three are in circulation, and Note My reads, writes and converts all three.
| Name | Characters | Where it comes from |
|---|---|---|
| LF | One line feed | macOS, Linux, and nearly every code repository. The default for a new document. |
| CRLF | A carriage return, then a line feed | Windows, and most things that pass through it. Two characters per line, which is what makes a file differ byte-for-byte from an identical-looking one. |
| CR | One carriage return, no line feed | Very old Mac software and some legacy exports. Rare, and the most likely to confuse other tools. |
Line endings are not encoding. Encoding decides how a character becomes bytes; line endings decide what marks the end of a line. A file can be perfectly readable UTF-8 and still carry the wrong newline convention.
Reading the line-ending pill
The status bar carries a line-ending pill, and its label is the fastest answer to "what is in this file?". There are five labels to read.
- Mixed — more than one convention in one document. Act on this first: it is the likeliest cause of your problem, and it means a conversion will touch more lines than you expect.
- None — there are no line breaks to report on, as on a single-line config value or a pasted fragment.
- LF, CRLF or CR — the document is consistent, and this is the convention it uses throughout.
The pill is shown by default and can be turned off in Settings ▸ Line Endings. Leave it on if you often take files from other platforms.
Convert the whole document
-
Check what you have first
Look at the pill. If it says Mixed, you have two conventions in one file and converting will change more lines than you might expect. That is usually the point — but know it first.
-
Choose the ending you want
File ▸ Line Endings ▸ Convert to LF rewrites every line ending in the document to a single line feed. Convert to CRLF and Convert to CR sit beside it. One command settles the document in front of you, first line to last.
-
Save
The conversion is an edit like any other: undoable with ⌘Z, and not on disk until you press ⌘S. Until then the tab title carries a leading
*. -
Confirm the pill changed
It should now read the ending you asked for. If it still says Mixed, see troubleshooting below.
Conversion lives in File ▸ Line Endings, one menu away from wherever you are working, and the status-bar pill is where you read the result. Convert, glance at the pill, save.
Preserve Current Format, and what it means on save
The same menu carries Preserve Current Format, and a matching preference in Settings ▸ Line Endings is on by default. Preserving means a save writes back the convention the file already had. Open a CRLF file, edit three lines, save, and it is still a CRLF file. Nothing is normalised underneath you — which is exactly why converting has to be an explicit command.
Two other defaults in that pane matter. New documents are created with LF, and warn on mixed line endings is on, so a file carrying two conventions announces itself rather than waiting to be noticed.
The full report on a file's endings
The pill gives you the one-word answer. For the whole picture, File ▸ Line Endings ▸ Show Line Ending Details… opens a fuller report on the endings in the current document — the thing to reach for when the pill says Mixed and you want to understand the file before you change it. Read it first, convert second, and you will never be guessing about what a conversion is about to touch.
Seeing the endings in the text itself
Turn on View ▸ Show End of Line, or find the same switch in Settings ▸ Invisibles. Every line then carries a small LF, CRLF or CR label, so a mixed file becomes obvious at a glance. The toolbar Show Invisibles button covers the broader set: spaces, tabs and line endings together.
Three marker styles are available in Settings ▸ Invisibles.
| Style | What it draws |
|---|---|
| Symbols (default) | Quiet placeholders — · for a space, → for a tab, and the LF / CRLF / CR labels. |
| Code Points | Escape-style code points, independent of the file's encoding. |
| Bytes | The hex bytes as the document's own encoding will write them. A UTF-8 space is 20; the same space in UTF-16 LE is 20 00. |
Showing invisibles changes what you see and nothing else. No marker is written into your file. All four invisibles switches are off by default.
Files that mix two conventions
Mixed files are the common case — a document edited on two machines, or a patch applied with the wrong settings. Note My treats a mixture as information, not as damage to repair behind your back.
Our cleanup rules give CRLF / mixed line endings a category of its own, so the mixture is named and counted the moment you look. Every preset reports it and leaves the file exactly as it is: converting a mixed file stays your decision, made from the File menu when you are ready to make it.
Our advanced language identifier means the grade you are shown fits the file in front of you. In a Python file, mixed endings are flagged as a warning. In a shell script, as danger — the honest grade, because a stray carriage return becomes part of the last word on the line and the failure then reads as a missing interpreter. Treat a danger grade as worth acting on before you run the file; on a plain text document the same finding is usually a note to keep in mind rather than a fault to fix. All of this happens on your Mac: nothing is uploaded, there is no account, and the file never leaves the machine.
Lone carriage returns, and how the cleanup tools treat them
A carriage return with no line feed after it is a different problem, and one the cleanup tools will fix for you. Our cleanup rules treat Lone CR (no LF) as always wrong and turn it into a proper newline. It is covered by the Code-safe preset, which is the default, and by Aggressive; Safe and Prose leave it alone.
To act on it, open Clean ▸ Clean Invisible / Special Characters…. Choose Whole Document and press Scan. The left table lists every category with a count against each, so you can see at a glance whether lone carriage returns are your problem. The right table lists each finding by Line:Col, code point, category, action and risk, and a double-click takes you straight to it in the editor. Apply (N) performs the changes.
One other command touches CRLF. Clean AI Copy/Paste Markers clears the debris that arrives with text pasted in from elsewhere, and in a mixed document it can take stray carriage returns out along with the rest. It never puts them in. It is deliberately conservative — it removes only artefacts that cannot change your wording, punctuation, indentation or emoji, and anything needing a judgement call is reported to you rather than changed. When you want one specific convention applied across the whole file, convert from the File menu: that is the command built for the job, and it does it in a single step.
Converting as a recorded, repeatable step
If several open tabs need the same treatment, record the conversion once and play it back. Line-ending conversion is one of the actions our macro recorder covers, alongside encoding conversion, saving, Go to Line, find and replace, and bookmarks — so a repeat clean-up becomes one keystroke.
-
Record it
Press ⌥⌘R. Perform the conversion from the File menu, save, then press ⌥⇧⌘R to stop. A HUD counts the actions as you go, and a save sheet follows.
-
Play it back across every open tab
Press ⌥⌘P. The scope chooser offers Current Tab or All Open Tabs. A report sheet afterwards shows what succeeded, what was skipped and what failed.
-
Undo it in one step if it was wrong
One ⌘Z reverses the whole run rather than just its last step, and the Edit menu names it Macro Playback. ⎋ stops a run in progress.
Troubleshooting
The pill still says Mixed after converting
Check whether the file has been reloaded from disk since, or changed by something outside the app. If another program rewrote it while you had it open, the default Ask behaviour offers you Reload or Keep My Version — and choosing Reload brings back whatever is on disk, endings included, which takes your conversion with it. You are always asked when there are unsaved edits, whichever mode is set in Settings ▸ File Monitor. Convert again, then save.
The file looks unchanged after conversion
It will. Line endings are invisible by definition. Turn on View ▸ Show End of Line to see the labels, or read the pill. For byte-level certainty, switch the marker style to Bytes.
The conversion is not on disk
Converting edits the document; it does not save it. Look for the leading * on the tab title and press ⌘S.
The text is garbled as well as wrongly terminated
That is an encoding problem, not a line-ending one. File ▸ Encoding ▸ Reload with Encoding… re-opens the file with the encoding you pick — Windows-1252 covers a lot of older Western text. Our encoding handling leaves the file on disk untouched until you save, so a wrong choice costs nothing. Do not use Convert to Encoding… here; it writes out the text as you are currently seeing it, saving the mistake into the file. Fix the encoding first, then the line endings.
A shell script still will not run
Convert to LF and save, then read the first line closely. CRLF endings are a frequent cause, and a wrong interpreter path produces much the same complaint, so check both while you are there. Turn on View ▸ Show End of Line and look at the end of the shebang line: with the endings drawn in the text you can see straight away whether a carriage return is riding along on the end of the interpreter path.
Bringing a whole project into line
One file is a menu command. A folder full of them is a short routine, and every piece of it is already in front of you.
-
Open the files worth looking at
Search ▸ Find in Folder… (⇧⌘F) points at the project and searches for text the files in question share — a shebang line, an import, a phrase from the header. Narrow the sweep with a glob mask such as
*.shand skip the folders you never want touched. Results stream in grouped by file, and a double-click opens one at the matching line. The search only ever reads, so you can survey a directory you would rather not disturb and then open just the files you mean to change. -
Read the pills, tab by tab
With the files open, the status-bar pill answers the question as you move along the tab bar — and warn on mixed line endings, on by default, speaks up for the awkward ones before you have to go looking.
-
Convert, then record it once
File ▸ Line Endings ▸ Convert to LF sorts out the file in front of you. Our macro recorder turns that convert-and-save pair into a single keystroke you can run against All Open Tabs, which is the quickest way through a stack of files that all want the same treatment.
-
Let the defaults hold the line
New documents are created with LF, and preserving the current format on save keeps each converted file exactly as you left it. Once a file is right, it stays right — through every later edit and save.
The same routine works in the other direction. If a colleague needs a file back in Windows form, Convert to CRLF sits in the same menu, records just as readily into a macro, and reads back on the same pill.
Frequently asked questions
How do I know if a file has Windows line endings?
Read the line-ending pill in the status bar — it will say CRLF. For a line-by-line view, turn on View ▸ Show End of Line.
Will converting change anything other than the line endings?
It rewrites the terminators and nothing else — your wording, spacing and indentation all come through untouched — and as a normal edit ⌘Z reverses it.
Can I convert LF back to CRLF?
Yes — File ▸ Line Endings ▸ Convert to CRLF, in one step, over the whole document. Carriage returns only ever go in when you ask for them, so a file you have converted to LF stays that way until you say otherwise.
Why does my file keep saving with the old line endings?
Because preserving the file's existing format on save is on by default, and it is doing its job. Convert explicitly from the File menu and the saved file follows.
What line endings do new files get?
LF. That default lives in Settings ▸ Line Endings, alongside the preserve-on-save and warn-on-mixed switches.
Does the file get sent anywhere to be converted?
Everything happens on your Mac. Nothing is uploaded, there is no account, and the file never leaves the machine. The conversion happens in the document in front of you, and the result is on disk the moment you press ⌘S.