CSV Format Guide
Master CSV format, RFC 4180 standards, and best practices
What is CSV?
CSV (Comma-Separated Values) is a simple text format for storing tabular data. Each line represents a data record, and each record consists of fields separated by delimiters (typically commas). First standardized in RFC 4180 in 2005, CSV remains one of the most universal data exchange formats.
Despite its simplicity, CSV handles billions of data transfers dailyβfrom database exports to spreadsheet imports to API data exchange.
Basic CSV Structure
id,name,email,age,active 1,Alice Johnson,alice@example.com,30,true 2,Bob Smith,bob@example.com,25,false 3,Carol White,carol@example.com,35,true
Header Row
First line contains column names (optional but recommended)
Data Rows
Each subsequent line is a data record with same number of fields
RFC 4180 Standards
RFC 4180 defines the official CSV specification. Key rules include:
1. Line Breaks
Records separated by line breaks (CRLF or LF). Last record may or may not have ending line break.
2. Header Row (Optional)
First line may be a header with same format as normal records. Header field names should not contain line breaks or special characters.
3. Fields & Delimiters
Fields separated by commas. Each record must have same number of fields.
field1,field2,field34. Quoting Rules
Fields containing commas, line breaks, or double quotes must be enclosed in double quotes.
1,"Johnson, Alice","Says ""Hello"" to world",true5. Escaping Quotes
Double quotes within quoted fields must be escaped by doubling them.
"He said ""Hello"" to me" β He said "Hello" to meDelimiter Variations
While "CSV" means comma-separated, many systems use alternative delimiters:
| Format | Delimiter | Use Case |
|---|---|---|
| CSV | , (comma) | Standard US/UK format |
| SSV | ; (semicolon) | European Excel, avoids comma conflicts |
| TSV | \t (tab) | Better visual separation, rare in text |
| PSV | | (pipe) | Log files, database exports |
Character Encoding
Encoding issues are a common source of CSV problems, especially with international characters.
β οΈ Common Issues
- Excel opening UTF-8 files with garbled characters
- Accented characters (Γ©, Γ±, ΓΌ) displaying incorrectly
- Asian characters (δΈζ, ζ₯ζ¬θͺ) corrupted
- Emoji rendering as question marks
Encoding Best Practices
- UTF-8: Default choice for modern systems, supports all Unicode characters
- UTF-8 with BOM: Add byte order mark for Excel compatibility
- ISO-8859-1 (Latin-1): Legacy encoding for Western European languages
- Specify Encoding: Always document the encoding used
Handling Edge Cases
Empty Fields
1,Alice,,true β age field is empty 2,,bob@email.com, β name empty, active empty
Empty fields represented by adjacent delimiters
Line Breaks in Fields
1,Alice,"123 Main St Apt 4B New York, NY",true
Multi-line fields must be quoted
Leading/Trailing Spaces
1, Alice ,bob@email.com, true
RFC 4180: Spaces outside quotes preserved. Some parsers trim automatically.
CSV vs JSON
| Feature | CSV | JSON |
|---|---|---|
| Structure | Flat, tabular | Hierarchical, nested |
| Data Types | All strings | String, number, boolean, null |
| File Size | Smaller | Larger (verbose) |
| Human Readable | Very readable | Readable with formatting |
| Excel Compatible | Native support | Requires conversion |
| API Standard | Rare | De facto standard |
π‘ Need to Convert?
Our tool handles all CSV edge cases: custom delimiters, UTF-8 encoding, proper quoting, and validation.
Try CSV Converter βAuthored by: JSON CSV Converter
Last updated: February 15, 2026