A CSV file is a plain text file that stores tabular data, where each line represents a row and each value within that row is separated by a comma. The abbreviation stands for Comma-Separated Values, and what makes CSV files so useful is their simplicity: any spreadsheet app, database tool, or programming language can read them without needing a special decoder. If you have ever exported contacts from Gmail or downloaded a report from your bank, you have almost certainly already worked with a CSV file.
Content Table
What a CSV file actually looks like
Open any CSV file in a text editor and you will see something like this:
name,email,city
Alice,alice@example.com,London
Bob,bob@example.com,Toronto
Carol,carol@example.com,Sydney
The first line is the header row. It names each column:
name
,
email
, and
city
. Every line after that is one record, with values in the same order as the headers. The comma is the delimiter, the character that signals where one field ends and the next begins. That is the entire format. There is no binary encoding, no proprietary structure, no version number to worry about.
When you open that same file in Excel or Google Sheets, the app reads the commas and renders each value in its own cell, making the data look like a tidy table. The file itself has not changed at all. It is still plain text underneath.
The flat file structure explained
CSV is what developers call a flat file. Unlike a relational database, which links multiple tables together through relationships, a flat file keeps everything in a single, two-dimensional grid: rows and columns, nothing more. There is no nesting, no hierarchy, and no built-in concept of a relationship between tables.
This flat file structure is both a strength and a limitation. It is a strength because it is universally readable. It is a limitation because complex data (say, an order that contains multiple line items, each with its own product details) does not map cleanly into a single flat grid without duplication.
What are CSV files used for?
CSV files show up in practically every industry because they sit at the intersection of human-readable and machine-readable. Here are the most common real-world scenarios:
- Data exports and imports. CRM platforms like Salesforce, e-commerce tools like Shopify, and email services like Mailchimp all let you export records as CSV and import them into another system.
- Spreadsheet data exchange. When someone sends you a spreadsheet that needs to work in both Excel and Google Sheets without formatting conflicts, CSV is the safe, neutral format.
-
Database seeding.
Developers use CSV files to bulk-load initial data into a database using commands like
COPYin PostgreSQL orLOAD DATA INFILEin MySQL. - Analytics and reporting. Business intelligence tools like Tableau and Power BI accept CSV uploads as a quick way to visualize data without setting up a live database connection.
- Machine learning datasets. Many public datasets on platforms like Kaggle are distributed as CSV files because they are easy to parse with libraries like pandas in Python.
- Log files and sensor data. IoT devices and server logs often write readings as delimited text so they can be processed later without specialized software.
CSV and data portability
Data portability is the ability to move your data from one system to another without losing information or getting locked into a proprietary format. CSV is arguably the most important format for data portability in everyday use, precisely because it requires no special software to open, edit, or share.
The RFC 4180 specification (published by the Internet Engineering Task Force) defines a common format for CSV, including how to handle fields that contain commas or line breaks (wrap them in double quotes). Most tools follow this convention, which is a big reason why a CSV exported from one application almost always opens correctly in another.
This is also why regulators and open-data advocates tend to recommend CSV for public datasets. The U.S. government's open data portal publishes thousands of datasets in CSV format because it guarantees anyone can access the data regardless of what software they own.
CSV vs. other data formats
Knowing when to use CSV (and when not to) comes down to understanding what the alternatives offer.
| Format | Structure | Best For | Human Readable |
|---|---|---|---|
| CSV | Flat, tabular, delimited text | Simple row-and-column data, universal exchange | Yes |
| JSON | Hierarchical, key-value pairs | APIs, nested data, web apps | Yes |
| XML | Hierarchical, tag-based | Document data, enterprise systems | Mostly |
| TSV | Flat, tabular, tab-delimited | Data with embedded commas (e.g., addresses) | Yes |
| Excel (.xlsx) | Binary/ZIP-based spreadsheet | Rich formatting, formulas, charts | No (requires software) |
| Parquet | Columnar binary | Big data, analytics at scale | No |
TSV (Tab-Separated Values) is CSV's closest relative. The only difference is that it uses a tab character as the delimiter instead of a comma. This makes TSV a better choice when your data contains lots of commas naturally, such as addresses or product descriptions with prices.
Where CSV falls short
CSV is not a silver bullet. Here are the real pain points you will run into:
-
No data types.
Everything in a CSV is a string. There is nothing in the format itself that tells a program whether
42is a number,trueis a boolean, or2024-01-15is a date. The receiving application has to guess or be told. - No standard for encoding. A CSV saved as UTF-8 can look garbled when opened by software expecting Windows-1252. This is a surprisingly common source of broken characters, especially with non-English text.
- No schema or validation. Nothing in a CSV file enforces that column three is always a valid email address or that a required field is never empty. You only find out there is a problem when something breaks downstream.
- Poor fit for nested data. If an order has five line items, you either duplicate the order details on five rows or use a separate file, neither of which is elegant.
- No support for multiple sheets. Unlike Excel, a single CSV file can only hold one table. Multi-sheet workbooks require multiple CSV files.
1-2
to a date or
00123
to the number
123
, stripping your leading zeros. Always check critical fields after opening a CSV in Excel.
Converting CSV to other formats
One of the most common tasks once you have a CSV file is converting it into a format that fits your next step. For example, you might need to turn tabular CSV data into JSON to feed a web API, or into an HTML table to display it on a web page.
Data serialization formats like JSON and XML carry the same underlying information as CSV but add structure that makes the data easier for code to traverse. When you convert a CSV to JSON, each row typically becomes one object in an array, with the header row supplying the key names. That transformation makes the data immediately usable in JavaScript, Python, or any language with a JSON parser.
Similarly, converting CSV to an HTML table is a fast way to present data on a webpage without manually writing out every
<tr>
and
<td>
tag. The header row maps to
<th>
elements and each subsequent row becomes a
<tr>.
If you need to do any of these conversions quickly and without uploading your data to a remote server, browser-based tools handle the job entirely on your device. No file ever leaves your machine, which matters when the CSV contains sensitive information like customer records or financial data.
Convert your CSV file to JSON, HTML, XML, TSV, or YAML instantly
Our free browser-based CSV converters transform your CSV file into the format you need without uploading anything to a server. Paste your data or drop a file and get a clean, ready-to-use result in seconds.
Try the CSV Converter →
Yes. While the name says "comma," many tools produce CSV-like files that use semicolons, pipes, or tab characters as the delimiter instead. Tab-separated files are formally called TSV (Tab-Separated Values). Semicolons are common in European locales where commas are used as decimal separators in numbers. Most spreadsheet apps let you specify the delimiter when importing.
You can open a CSV file in Microsoft Excel, Google Sheets, LibreOffice Calc, or any plain text editor like Notepad or VS Code. Double-clicking the file on Windows usually opens it in Excel automatically. If the columns do not split correctly, use the "Import" option and specify the comma delimiter manually so the app parses it properly.
A plain CSV file cannot execute code on its own, so it is generally safe. However, if you open a CSV in Excel, it can trigger a feature called CSV injection, where a cell value starting with
=
,
+
, or
-
is treated as a formula. Malicious actors can use this to run macros or exfiltrate data. Always be cautious opening CSV files from untrusted sources in spreadsheet software.
A CSV file is plain text with no formatting, formulas, charts, or multiple sheets. An Excel file (.xlsx) is a compressed binary format that supports all of those features. CSV is universally compatible and small in size. Excel is richer but requires Microsoft Office or a compatible app to open correctly. When you save an Excel workbook as CSV, all formatting and formulas are stripped out.
There is no hard size limit defined in the CSV format itself. In practice, Excel caps its row count at 1,048,576 rows per sheet, so very large CSV files will be truncated if you open them there. For files with millions of rows, command-line tools like
awk
, database import utilities, or Python's pandas library are much better choices than a spreadsheet application.
Yes, encoding matters more with CSV than with formats like JSON, which defaults to UTF-8. A CSV saved in Windows-1252 encoding can display garbled characters when opened by a UTF-8 expecting tool. Always save and share CSV files as UTF-8 when possible, and add a BOM (byte order mark) if you need Excel to recognize the encoding automatically on Windows.