📊CSV Import Templates
UTF-8 with BOM Guidance
Handling UTF-8 encoding with BOM for special characters in CSV files.
Explanation
BOM (Byte Order Mark) helps Excel correctly detect UTF-8 encoding for international characters.
Examples
With Special Characters
Output
name,city,country Müller,München,Deutschland François,Paris,France Đorđe,Beograd,Srbija
Code Examples
JavaScript
// Add BOM to CSV for Excel compatibility
function addBOM(csvContent) {
const BOM = '\uFEFF';
return BOM + csvContent;
}
// Generate CSV with BOM
const csv = addBOM('name,city\nMüller,München');
const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
// Download
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = 'data.csv';
link.click(); Python
import csv
# Write CSV with UTF-8 BOM
with open('data.csv', 'w', encoding='utf-8-sig', newline='') as f:
writer = csv.writer(f)
writer.writerow(['name', 'city'])
writer.writerow(['Müller', 'München'])Try it Now
💡 Tips
- Always use UTF-8 encoding for international content
- Add BOM for Excel compatibility
- Test with actual special characters before bulk import
- Document encoding requirements for users
⚠️ Common Pitfalls
- BOM may cause issues with some parsers
- Different systems expect different encodings
- Excel on Mac handles encoding differently
- Without BOM, Excel may show garbled characters