Fundamentals

What is CSV? The Complete Guide to Comma-Separated Values

6 min read
January 22, 2026
what is csv, csv format, csv file

CSV (Comma-Separated Values) is the simplest and most widely supported format for tabular data. If you've ever exported data from Excel, imported contacts to your phone, or migrated data between systems, you've used CSV.

This guide explains the CSV format, its strengths and limitations, and when to choose CSV over alternatives like JSON or Excel.

What is CSV?#

CSV stands for Comma-Separated Values. It's a plain text format where:

  • Each line represents a row (record)
  • Values within a row are separated by commas
  • The first row typically contains column headers

CSV files have been around since the 1970s, predating most modern formats. Their simplicity is their greatest strength — any text editor can open them, and virtually every programming language and spreadsheet application supports them.

users.csvcsv
name,email,age,city
John Doe,john@example.com,30,New York
Jane Smith,jane@example.com,25,London
Bob Johnson,bob@example.com,35,Tokyo

CSV Structure & Rules#

While CSV seems simple, there are important rules to follow:

Basic Rules:

  1. Delimiter — Commas separate values (some regions use semicolons)
  2. Line ending — Each row ends with a newline (CRLF or LF)
  3. Quoting — Values containing commas, quotes, or newlines must be enclosed in double quotes
  4. Escaping quotes — Double quotes inside quoted fields are escaped by doubling them: ""

Handling Special Characters:

special-chars.csvcsv
name,description,price
"Widget, Large",Standard widget with comma,19.99
"Quote Test","He said ""Hello""",29.99
"Multiline
Description","This spans
multiple lines",39.99

Advantages of CSV#

CSV remains popular for good reasons:

  • Universal Compatibility — Opens in Excel, Google Sheets, Numbers, and any text editor
  • Small File Size — 50-60% smaller than equivalent JSON for tabular data
  • Human Readable — Easy to inspect and edit manually
  • Fast Processing — Streaming parsers can handle massive files efficiently
  • Database Friendly — Easy to import/export from SQL databases
  • No Dependencies — No special libraries needed to read/write

Limitations of CSV#

CSV has significant limitations you should be aware of:

  • No Data Types — Everything is a string. Numbers, dates, and booleans have no inherent type.
  • No Nesting — Cannot represent hierarchical or nested data structures.
  • No Standard — Different applications handle edge cases differently.
  • Encoding Issues — UTF-8 handling varies. Excel sometimes expects BOM.
  • No Metadata — Cannot include schema, comments, or additional information.

When CSV Causes Problems:

  • Dates like "01/02/2024" — Is this January 2nd or February 1st?
  • Numbers like "001234" — Leading zeros may be stripped
  • Large numbers — Excel may convert to scientific notation

CSV vs JSON: When to Use Each#

Both formats have their place. Choose based on your use case:

Use CaseBest FormatWhy
Spreadsheet workCSVNative Excel/Sheets support
API responsesJSONSupports nested data and types
Configuration filesJSONStructured and typed
Database export/importCSVUniversal SQL support
Data interchangeJSONLanguage-agnostic with types
Large datasetsCSVSmaller size, streaming support
Complex nested dataJSONSupports hierarchy

Working with CSV Files#

Here's how to work with CSV in common languages:

JavaScript (Browser)

// Simple CSV parser (for basic CSV without quotes)
function parseCSV(text) {
  const lines = text.trim().split('\n');
  const headers = lines[0].split(',');
  
  return lines.slice(1).map(line => {
    const values = line.split(',');
    return headers.reduce((obj, header, i) => {
      obj[header] = values[i];
      return obj;
    }, {});
  });
}

// Usage
const csv = "name,age\nJohn,30\nJane,25";
const data = parseCSV(csv);
// [{ name: "John", age: "30" }, { name: "Jane", age: "25" }]

CSV Best Practices#

Follow these guidelines for reliable CSV files:

  1. Always include headers — First row should name each column
  2. Use UTF-8 encoding — Add BOM for Excel compatibility if needed
  3. Quote fields with special characters — Commas, quotes, newlines
  4. Use ISO 8601 dates — YYYY-MM-DD format is unambiguous
  5. Escape quotes properly — Double them: ""
  6. Validate before processing — Check row lengths match header count

Frequently Asked Questions

What does CSV stand for?
CSV stands for Comma-Separated Values. It's a plain text format where data values are separated by commas, with each line representing a row of data.
Can Excel open CSV files?
Yes, Excel natively supports CSV files. Simply double-click a .csv file to open it in Excel, or use File > Open. Note that Excel may change number formatting, so always check your data after opening.
How do I handle commas inside CSV values?
Wrap the entire value in double quotes. For example: "New York, USA" will be treated as a single value containing a comma.
What's the difference between CSV and Excel (.xlsx)?
CSV is plain text with just data values. Excel files (.xlsx) are binary files that include formatting, formulas, multiple sheets, charts, and more. CSV is simpler and more portable, while Excel is feature-rich.
Can CSV store multiple sheets like Excel?
No, a CSV file can only contain one table of data (one "sheet"). For multiple sheets, you'd need separate CSV files or use Excel/XLSX format.

Convert JSON to CSV Instantly

Need to convert JSON data to CSV for Excel or data analysis? Our free converter handles nested objects and large files.

Try JSON to CSV Converter

Related Articles