All posts

How to Change a CSV's Line Endings (CRLF to LF, and Add a BOM for Excel)

··3 min read

To change a CSV's line endings, rewrite every row break as the ending your importer expects: CRLF for Excel and Windows, LF for Unix, Linux and most web tools. The CSV line ending converter does it in your browser. Upload a CSV or .xlsx file, or paste it with a header row, pick CRLF, LF or old Mac CR, choose whether to add a UTF-8 byte order mark, and download the file.

Nothing is uploaded. The file is read on your device.

Why line endings break imports

Windows ends a line with two characters, carriage return and line feed (CRLF). Unix, Linux and current macOS use one, line feed (LF). Very old Mac files used a lone carriage return (CR). Some importers read a whole CR file as one long row, and some scripts keep a stray carriage return on the end of the last column. The symptom is usually one row that holds the whole file, or a last column whose values will not match anything.

Doing it by hand

  • See what you have. On macOS or Linux, file leads.csv reports "with CRLF line terminators" when the file uses CRLF.
  • CRLF to LF. sed 's/\r$//' leads.csv > leads-lf.csv, or dos2unix leads.csv if you have it.
  • LF to CRLF. unix2dos leads.csv, if installed.
  • Old Mac CR to LF. tr '\r' '\n' < old.csv > new.csv.
  • In Excel. Save As offers "CSV (Comma delimited)" and "CSV UTF-8 (Comma delimited)", which write Windows endings, and a Macintosh CSV option, which writes CR. Excel will not give you LF.

Command-line edits are quick, but they work on the raw bytes, so a line break inside a quoted cell is changed too.

Step 1: load the file

Upload the CSV or .xlsx, or paste the cells with the header row first. The tool reads the file whatever its endings were, including an old Mac CR file.

Step 2: pick the ending and the options

Choose Windows (CRLF), Unix and modern Mac (LF) or old Mac (CR). Tick the byte order mark if the file will be opened in Excel, and tick quote every value if your importer needs it. When the importer's help page does not say, LF is the safest choice for web tools and CRLF for Excel.

Step 3: check the size and download

The file size shown is the exact number of bytes you will download, which helps when an importer has a size limit.

What the byte order mark does

A byte order mark (BOM) is three bytes at the very start of a UTF-8 file. Excel uses it to know the file is UTF-8, so José or Zoë show correctly instead of as odd symbols. Many web importers and scripts do not expect it and read it as part of the first column name, so leave it off for those. If accents already look wrong, the file may have been saved in another encoding. Start with our guide to fixing garbled characters in a CSV.

Line breaks inside cells

A quoted cell can hold a line break, such as a multi-line note. The tool writes those breaks with the same ending as the rows and tells you how many rows had one. To remove them instead, use the whitespace and hidden character cleaner, or see cleaning CSV columns before import.

What this tool cannot do

  • It rewrites the CSV from its parsed cells, so the original quoting style is not kept.
  • It cannot repair a file saved in the wrong text encoding. For that, use the CSV encoding fixer.
  • Only the first sheet of a workbook is read.
  • A byte order mark helps Excel but can confuse tools that do not expect it.

Check the addresses before you import

A clean file still has to hold addresses that work. Upload your list on the verify page: the first 100 email checks are free with a Google sign-in, no card. Each address comes back valid, risky or invalid with a reason, and nothing is sent to anyone on the list. For larger lists, see bulk email verification and pricing.

Convert your file now

Open the CSV line ending converter.

Common questions

How do I change a CSV from CRLF to LF?

On macOS or Linux run sed 's/\r$//' in.csv > out.csv, or use dos2unix if it is installed. Without a command line, a CSV line ending converter rewrites every row with the ending you pick.

Which line ending should I use?

CRLF for Excel and Windows tools, LF for Unix, Linux and most web importers. The importing tool's help page usually says which it wants.

What is a byte order mark?

Three bytes at the start of a UTF-8 file. Excel uses them to know the file is UTF-8, so names such as José show correctly. Many web importers read them as part of the first column name, so leave them off for those.

Does the converter change my data?

No. Only the row endings, the optional quotes and the optional byte order mark change. The cells keep their text.

Is my file uploaded?

No. The tool reads it in your browser and nothing leaves your device.

Check your list before you send

Real mailbox checks over SMTP, and nothing is sent to the address. Sign in with Google and your first 100 email checks are free, no card. Plans for bigger lists are on the pricing page.