What Is a CSV File (and Why Every Tool Imports and Exports One)
A CSV is a plain text file where each row is a line and each column is separated by a comma. That is the whole spec. Despite being that simple, CSV is the universal interchange format for tabular data: every spreadsheet, database, CRM, analytics tool, and accounting app can import and export it. Here is why it has lasted 50 years and what to watch for.
A CSV is a plain text file with one row per line, columns separated by commas. That is the whole spec. Despite being that simple, it is the universal interchange format for tabular data because every tool can read and write plain text. The two things to watch for: (1) the delimiter is not always a comma (TSV uses tab, semicolon is common in European locales), and (2) fields with the delimiter character inside them (commas in numbers, quotes in text) need to be wrapped in quotes, and the quotes need to be escaped by doubling them. The <a href="/csv-json-converter">CSV to JSON Converter</a> on this site handles the parsing, the escaping, and the conversion. For one-off conversions, paste the CSV, get JSON back, copy, paste into your tool.
A CSV file is the most universally supported data format in computing. Every spreadsheet app (Excel, Google Sheets, Numbers, LibreOffice Calc) can read and write it. Every database can import and export it. Every programming language has a parser for it. Every CRM, analytics tool, accounting app, and email-marketing platform can ingest it. It has been the de facto standard for tabular data exchange since the 1970s, and it is not going to be replaced in the next decade.
This is what a CSV file looks like and why it is structured that way.
The basic structure
A CSV file is a plain text file where each row is a line, and each column is separated by a comma. The first row is usually the header (the column names). The remaining rows are the data.
name,age,city
Alice,34,Seattle
Bob,29,Austin
Carol,41,Denver
That is the whole spec. Three lines of plain text, one row per line, one column per comma. Any text editor can open this file, and any tool that handles CSV can parse it.
The simplicity is the point. CSV is the lowest common denominator of tabular data: it is human-readable, machine-parseable, and works on any device that has a text editor. The format is the "ASCII of structured data" — every system that handles text can handle CSV, and the format has not changed in 50 years because it does not need to change.
The first row is usually a header
The first row of a CSV is usually the column names. This is convention, not spec — a CSV without a header is valid, just less self-describing.
name,age,city
Alice,34,Seattle
Bob,29,Austin
Carol,41,Denver
Here, the first row name,age,city is the header. The next three rows are the data. Tools that import CSV usually use the header row to identify the columns; tools that export CSV usually write the header row automatically.
If a CSV does not have a header, the importing tool has to guess the column names, or the user has to specify them manually. Most tools assume there is a header by default; you can usually turn this off in the import settings.
The delimiter is not always a comma
CSV stands for "comma-separated values." The comma is the default. But not every file that ends in .csv uses a comma. Common alternatives:
- Tab-separated values (TSV): same structure, but columns are separated by tabs. Common in databases, Unix tools, and copy-paste from spreadsheets.
- Semicolon-separated values (SSV): common in European locales, where the decimal separator is a period and the comma is reserved for the decimal part of numbers. Excel in German or French defaults to semicolons.
- Pipe-separated values (PSV): less common, used in some legacy systems.
The file extension is not a reliable signal of the delimiter. .csv usually means comma, but it can mean anything. .tsv usually means tab. The reliable signal is to open the file in a text editor and see what the separator is. The CSV to JSON Converter on this site lets you pick the delimiter when you paste.
The quoting rules (this is the part people get wrong)
CSV has a simple rule for fields that contain the delimiter or other special characters: wrap the field in double quotes, and escape any double quotes inside the field by doubling them.
Example: a field with a comma in it.
name,address
Alice,"123 Main St, Apt 4"
The field 123 Main St, Apt 4 contains a comma, so it is wrapped in double quotes. Without the quotes, the parser would split the field at the inner comma and treat Apt 4 as a separate column.
Example: a field with a double quote in it.
name,quote
Alice,"She said ""Hello"" to me"
The field contains a double quote, so the inner double quote is escaped by doubling it (""). The wrapping quotes are required. The parser sees "" and interprets it as a single literal ".
Example: a field with a newline in it.
name,notes
Alice,"Line 1
Line 2"
Newlines inside a field are allowed if the field is wrapped in double quotes. The parser knows to keep reading until the closing quote, even across line breaks.
The quoting rules are part of the official CSV specification (RFC 4180), and most tools follow them. The exceptions are usually Excel and other tools that have their own dialect of CSV with slightly different quoting. If you are exporting data and the importing tool is misbehaving, check whether both tools are using the same dialect (most are, but Excel has historical quirks).
Encoding: usually UTF-8, sometimes not
CSV files are plain text, so they have a character encoding. The modern default is UTF-8 (the same encoding the web uses). Older CSV files, especially those exported from Excel on Windows, may use a different encoding (Windows-1252, Latin-1, etc.) which can cause non-ASCII characters to look garbled when imported.
The fix is to either:
- Save the file as UTF-8 before sharing it. Most modern tools default to UTF-8; you usually have to look in the export options to find the encoding setting.
- Tell the importing tool what encoding to use. Most import dialogs have an "encoding" or "character set" option.
If you see garbled characters in a CSV (e.g., José instead of José), the encoding is wrong. Convert the file to UTF-8 and re-import.
Why CSV has lasted 50 years
CSV is the universal interchange format for tabular data because it has the minimum properties needed to be useful and no more. The format is:
- Human-readable: any text editor can open it. Any human can read it.
- Machine-parseable: any programming language can parse it with a few lines of code.
- Portable: works on any device, any OS, any tool.
- Durable: a CSV file written in 1974 is readable in 2024 with no conversion.
- Compact: no binary overhead, no metadata, no schema. Just the data.
Compare with modern alternatives:
- JSON: works for nested data, but harder to scan visually. Better for APIs, worse for human inspection.
- XML: works for structured data with schema, but verbose and noisy. Better for documents, worse for tabular data.
- Parquet: works for huge datasets, but binary and not human-readable. Better for data warehousing, worse for sharing.
- Excel .xlsx: works for spreadsheets, but binary and Microsoft-specific. Better for editing, worse for interchange.
CSV is the worst at each of these tasks except for the basic one: passing a table of data between two tools that both support plain text. For that task, it is the best. The format has been the standard for 50 years because it is the simplest thing that works, and that is unlikely to change.
Common operations on CSV files
Import into a database
Every relational database (PostgreSQL, MySQL, SQLite, etc.) has a CSV import command. The standard flow:
-- PostgreSQL
COPY users (name, age, city) FROM 'users.csv' WITH (FORMAT csv, HEADER true);
-- MySQL
LOAD DATA INFILE 'users.csv' INTO TABLE users
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '
'
IGNORE 1 ROWS;
-- SQLite
.mode csv
.import users.csv users
The exact syntax varies, but the pattern is the same: tell the database where the file is, what delimiter and quote character to use, and whether to skip the first row (the header).
Import into a spreadsheet
Excel, Google Sheets, Numbers, and LibreOffice Calc can all open CSV files directly. The first row is treated as the header. Numbers in the file are parsed as numbers; everything else is parsed as text. If a column has mixed types (some cells as numbers, some as text), the column is usually treated as text to avoid data loss.
Import into a programming language
Python's csv module, Ruby's CSV class, JavaScript's Papa Parse, and the CSV libraries for Go, Rust, and Java all handle the quoting and delimiter rules correctly. The CSV to JSON Converter on this site handles the parsing, the quoting, and the conversion in the browser — no upload, no server.
Convert to JSON
For data that will be consumed by a web app or an API, JSON is the better format. The conversion is straightforward: each row becomes an object, with the header row providing the keys.
// CSV
name,age,city
Alice,34,Seattle
// JSON
[
{"name": "Alice", "age": 34, "city": "Seattle"}
]
The CSV to JSON Converter on this site does this conversion in the browser. Paste the CSV, get JSON back, copy into your tool.
Merge multiple CSV files
The Text Diff tool on this site is for comparing two files. For merging multiple CSVs (e.g., the same data exported by different tools), a small script is usually easier. The pattern is to load all files, concatenate the rows, and write back. The Word Counter on this site is the kind of tool that works on the merged result.
When NOT to use CSV
CSV is not the right format when:
- Nested or hierarchical data: JSON or XML is better. CSV is a flat table; nested structures need a self-describing format.
- Huge datasets (millions of rows): Parquet or another columnar format is better. CSV is a row format; scanning millions of rows is slow.
- Schema validation matters: JSON Schema or XML Schema is better. CSV has no built-in schema; you validate the columns by convention.
- Binary data (images, files): not CSV. CSV is text only.
For the common case — a table of data with a few hundred to a few hundred thousand rows, exchanged between two tools that both support plain text — CSV is the right answer. It is not the most efficient format, the most expressive format, or the most modern format. It is the most universal format, and for interchange, universality is the property that matters most.
The honest summary
A CSV file is plain text with rows separated by newlines and columns separated by commas. That is the whole spec. The format is 50+ years old, will be readable in 100+ years, and is the universal interchange format for tabular data because every tool that handles plain text can handle CSV. The two things to watch for: (1) the delimiter is not always a comma (TSV uses tab, semicolon is common in European locales), and (2) fields with the delimiter or special characters need to be wrapped in double quotes, with inner double quotes escaped by doubling. The CSV to JSON Converter on this site handles the parsing, the quoting, and the conversion in your browser. For one-off conversions, paste the CSV, get JSON back, copy, paste into your tool. The format has not changed in 50 years because it does not need to change. It is the simplest thing that works, and that is unlikely to change in the next 50 either.