← Cheat Sheets
CSV Format Rules
Write CSV that opens correctly everywhere.
# CSV Format Rules
Write CSV that opens correctly everywhere.
- One record per line; first line is usually the header
- Separate fields with commas (some regions use semicolons: check the target program)
- Wrap a field in double quotes if it contains a comma, quote or newline
- Escape a quote inside a quoted field by doubling it: `"He said ""hi"""`
- Use UTF-8 (add a BOM only if Excel garbles characters)
- Keep the same number of fields in every row
- Write dates as `YYYY-MM-DD` and numbers without thousands separators
```csv
name,city,note
Ann,Oslo,"Likes tea, coffee"
Bo,Rome,"Said ""hello"""
```