What a CSV file is and why you might need one

A CSV file (comma-separated values) is a plain text document that stores data in rows and columns, separated by commas. When you open it in a spreadsheet program like Excel or Google Sheets, it looks like a normal table. But underneath, it's just text — which is why CSV files work on any computer, any operating system, and any program that reads spreadsheets.

You create a CSV file when you need to move data between programs that don't normally talk to each other, or when you want a file format that will still be readable ten years from now. A CSV file won't break if you upgrade your software. It's also smaller than an Excel file and loads faster on older computers.

The most common reason to make a CSV file is to export data from one program and import it into another — moving contacts from your email to your phone, uploading a customer list to an accounting program, or sharing a spreadsheet with someone who uses different software than you do.

Key Takeaways

  • You can create a CSV file by saving a spreadsheet as CSV format in Excel, Google Sheets, or by typing data directly into a text editor like Notepad.
  • The first row should contain column headers (like "Name", "Email", "Phone") so the receiving program knows what each column contains.
  • Commas separate the columns, so if your data contains a comma, you must wrap that cell in quotation marks to avoid breaking the file.
  • You can open and edit a CSV file in any spreadsheet program, but saving it back as CSV will strip out formatting like bold text and colored cells.

Creating a CSV file from an existing spreadsheet in Excel

If you already have data in an Excel file, the fastest way to turn it into a CSV is to save it with a different file type. Open your spreadsheet in Excel, then click File in the top left corner.

Select Save As. A dialog box will open asking where you want to save the file and what to name it. In the dropdown menu labeled Save as type, scroll down and select CSV (Comma delimited) (*.csv). Type a name for your file in the filename box — for example, "customer_list" — and click Save.

Excel will warn you that the file may contain features that are not compatible with CSV format. This is normal. Click Yes to confirm. Your file is now saved as a CSV. You can open it again in Excel or any other spreadsheet program, and it will look the same as before.

Creating a CSV file from Google Sheets

In Google Sheets, open the spreadsheet you want to convert. Click File at the top left, then hover over read to see a submenu of file formats.

Click Comma Separated Values (.csv). Your browser will read the file to your computer's Downloads folder with the same name as your Google Sheet. If you want to rename it first, go back to the spreadsheet, click the title at the top, type a new name, and press Enter. Then read it again.

Google Sheets will only read the sheet you are currently viewing. If your spreadsheet has multiple sheets (tabs at the bottom), you will need to read each one separately as its own CSV file.

Creating a CSV file from scratch in a text editor

If you don't have spreadsheet software or you want to build a CSV file manually, you can type one directly into a text editor like Notepad (Windows) or TextEdit (Mac). Open Notepad or your text editor and type your data with commas between each column and a line break between each row.

Here is an example of what the raw text looks like:

Name,Email,Phone John Smith,john@example.com,555-1234 Sarah Jones,sarah@example.com,555-5678 Mike Brown,mike@example.com,555-9999

The first row contains the column headers. Each row after that is one record. Commas separate the columns. When you are done typing, click File, then Save As. Type a filename ending in .csv — for example, "contacts.csv" — and click Save. Make sure you save it as plain text, not as a Word document or rich text file.

Handling commas and special characters in your data

If one of your data cells contains a comma, you must wrap that entire cell in quotation marks so the program reading the file knows the comma is part of the data, not a column separator. For example, if a customer's address is "123 Main St, Apt 4", you would type it like this:

Name,Address,City John Smith,"123 Main St, Apt 4",Boston

If your data contains quotation marks, you need to escape them by typing two quotation marks in a row. For example, if someone's name is O'Brien, you would type it as O''Brien. Most spreadsheet programs handle this automatically when you save as CSV, but if you are typing the file manually, this is the rule to follow.

Line breaks inside a cell also need quotation marks around the entire cell. If you have a note that spans two lines, wrap the whole note in quotes and press Enter within the cell to create the line break.

Opening and editing a CSV file

You can open a CSV file in Excel, Google Sheets, or any spreadsheet program by double-clicking it or by using File > Open within the program. The file will display as a normal spreadsheet with rows and columns.

When you edit a CSV file and save it, the program will ask you to confirm that you want to save it as CSV format. If you click No, it will offer to save it as an Excel file instead, which preserves formatting like bold text and cell colors. If you click Yes, it saves as CSV and removes all formatting — the file will contain only the text data.

If you open a CSV file in a text editor, you will see the raw comma-separated text. You can edit it directly, but you need to be careful to keep the commas in the right places and maintain the structure. Most people use a spreadsheet program instead because it is easier to see what you are doing.

Checking your CSV file before you use it

Before you upload a CSV file to another program or send it to someone else, open it in a spreadsheet program and scan it for errors. Check that the column headers are in the first row, that all rows have the same number of columns, and that no data is cut off or misaligned.

If a column looks too narrow to display all the text, click and drag the column border to widen it. If you see data that looks wrong — for example, a name split across two columns when it should be in one — go back to the original file, fix the problem, and save it again as CSV.

Some programs that import CSV files are strict about the format. They may require specific column headers, a certain number of columns, or data in a particular order. Check the documentation for the program you are importing into before you finalize your CSV file.

Frequently Asked Questions

Can I use a CSV file on a Mac if I created it on Windows?

Yes. CSV files are plain text and work on any computer and any operating system. A CSV file created on Windows opens the same way on a Mac, and vice versa. The only difference is where you save the file on your computer.

What is the difference between CSV and Excel format?

CSV is plain text with commas between columns. Excel format (.xlsx) is a compressed file that can store formatting, formulas, multiple sheets, and images. CSV is simpler and more universal; Excel is more powerful but only works in spreadsheet programs. Use CSV when you need to move data between different programs or keep a file that will work forever.

Will I lose my data if I save an Excel file as CSV?

The text data stays the same, but formatting disappears. Bold text, colored cells, formulas, and multiple sheets are removed when you save as CSV. If you need to keep the formatting, save a copy as Excel format instead and keep the CSV as a separate export file.

Can I create a CSV file on my phone?

Most phone spreadsheet apps (like Google Sheets or Excel Mobile) can open CSV files, but creating one from scratch is difficult on a small screen. It is easier to create the CSV on a computer and then open it on your phone if you need to view or edit it there.

What if the program I am importing into does not recognize my CSV file?

Check that the file ends in .csv, not .txt or another extension. Open the file in a spreadsheet program and verify that the column headers match what the receiving program expects. If the program requires a specific format or order, rearrange your columns to match. Save it again as CSV and try importing once more.