FormatForge

What is CSV?

CSV (Comma-Separated Values) is a simple, plain-text format for storing tabular data. Each line in a CSV file represents a row, and values within each row are separated by commas. It's the most widely supported format for data exchange between spreadsheets, databases, and applications.

CSV Format Structure

A CSV file consists of records (rows) with fields (columns) separated by a delimiter, typically a comma. The first row often contains column headers.

Basic CSV Example

name,age,email,city
John Doe,30,john@example.com,New York
Jane Smith,25,jane@example.com,Los Angeles
Bob Johnson,35,bob@example.com,Chicago

Key Features

  • Plain text - Can be opened with any text editor
  • Human readable - Easy to understand at a glance
  • Universal support - Works with Excel, databases, programming languages
  • Compact - Minimal overhead compared to other formats

CSV Syntax Rules

While CSV seems simple, there are important rules for handling special cases:

Handling Commas in Values

If a value contains a comma, it must be enclosed in double quotes:

name,address,phone
"Smith, John","123 Main St, Apt 4",555-1234

Handling Quotes in Values

If a value contains double quotes, they must be escaped by doubling them:

product,description
Widget,"A ""great"" product for everyone"

Handling Line Breaks

Values with line breaks must be enclosed in quotes:

id,notes
1,"First line
Second line"

Common Delimiters

While commas are standard, other delimiters are sometimes used:

  • Comma (,) - Standard CSV
  • Semicolon (;) - Common in European locales where comma is the decimal separator
  • Tab (\t) - TSV (Tab-Separated Values)
  • Pipe (|) - Sometimes used for data that may contain commas

CSV Use Cases

Data Export/Import

Export data from databases, CRMs, or analytics tools for analysis in spreadsheets.

Spreadsheet Exchange

Share data between Excel, Google Sheets, and other spreadsheet applications.

Bulk Data Operations

Import large datasets into databases or perform bulk updates.

Data Migration

Transfer data between different systems or platforms.

CSV vs Other Formats

FeatureCSVJSONExcel
Data typesText onlyString, number, boolean, nullFull type support
Nested dataNoYesLimited
FormattingNoNoYes
File sizeSmallestSmallLarger
Human readableYesYesNo (binary)

Tips for Working with CSV

  • Always include headers - Makes data self-documenting
  • Use consistent formatting - Same date format, number format throughout
  • Handle encoding properly - Use UTF-8 for international characters
  • Add BOM for Excel - Helps Excel recognize UTF-8 encoding
  • Validate before importing - Check for consistent column counts

Related Tools