CSV (Comma-Separated Values) is a plain-text file format that stores tabular data using commas to separate fields and newlines to separate records. It’s one of the oldest and most universally supported data exchange formats.
Format basics
A CSV file typically starts with a header row defining column names, followed by data rows:
name,email,role
Ada Lovelace,ada@example.com,engineer
Grace Hopper,grace@example.com,admiral
That’s it. No schema, no metadata, no nesting. This simplicity is both CSV’s strength and its weakness.
The quoting problem
When field values contain commas, newlines, or double quotes, they must be enclosed in double quotes. A double quote inside a quoted field is escaped by doubling it:
name,bio
"Smith, John","He said ""hello"" and left"
There’s an informal standard (RFC 4180) that defines these rules, but many tools deviate from it. Some use semicolons as delimiters (common in European locales where commas are decimal separators). Some use tabs (TSV). This inconsistency is the source of endless parsing headaches.
Why developers use CSV
CSV is the universal data interchange format for tabular data. Every spreadsheet application (Excel, Google Sheets, LibreOffice) reads and writes CSV. Every database can import and export it. Every programming language has CSV parsing libraries.
Common use cases include:
- Database exports and migrations
- Analytics data pipelines
- Financial data feeds
- Log file exports
- Bulk data imports for web applications
- Machine learning datasets
Limitations
CSV has no standard way to represent data types — everything is a string. Dates, numbers, booleans, and nulls are all ambiguous. There’s no support for hierarchical or nested data. Character encoding isn’t specified in the format itself, leading to frequent UTF-8 vs. Latin-1 issues.
For structured data with types and nesting, JSON or Parquet are better choices. For human-edited configuration, YAML wins.
Practical tips
- Always quote fields that might contain commas or newlines
- Use UTF-8 encoding with a BOM if Excel compatibility matters
- Specify the delimiter explicitly when parsing — don’t assume commas
Convert between CSV and JSON with JSON to CSV and CSV to JSON. Pull specific columns from CSV files with the CSV Column Extractor.