ConvertCSV

File Encoding Explained: UTF-8, ANSI, and BOM for CSV

By Convert CSV Editorial TeamLast updated August 1, 2026

File encoding explained for CSV and data files. Learn UTF-8 vs ANSI/Windows-1252, what a BOM does, and how to fix mojibake before you convert.

Encoding Is How Bytes Become Characters

A CSV file is a sequence of bytes. Encoding is the map from those bytes to letters, digits, and symbols. Pick the wrong map and "é" becomes "é"—or the importer rejects the file entirely.

The Encodings You Actually Meet

You do not need every code page—just the common ones in US/UK/EU business files.

EncodingWhere it shows upGuidance
UTF-8Modern exports, web, APIsDefault for new work
UTF-8 with BOMExcel on Windows exportsOK for Excel; some tools hate BOM
Windows-1252 ("ANSI")Legacy Windows/Excel CSVRe-encode to UTF-8 when possible
ISO-8859-1Older European systemsSimilar issues to 1252
UTF-16Some Windows notepad savesAvoid for CSV interchange

What Is a BOM?

A Byte Order Mark is a few invisible bytes at the start of a file (for UTF-8: EF BB BF). Excel often uses a UTF-8 BOM so it opens characters correctly. Some parsers then treat the first header as "\uFEFForder_id" unless BOM handling is enabled.

  • Excel-friendly UTF-8 CSV → BOM can help on Windows.
  • Developer pipelines → prefer UTF-8 without BOM, or strip it on read.
  • Never mix "I thought it was ASCII" with a BOM-prefixed header.

Step-by-Step: Diagnose Encoding Problems

Symptoms first, then fix.

  • Look for mojibake (é, ’) or replacement characters (�).
  • Check whether only non-English text breaks.
  • Open the file in a tool that shows encoding (editor, Online CSV Editor after re-save).
  • Re-export from the source as UTF-8 when you control the export.
  • If not, convert Windows-1252 → UTF-8 with a known decoder, then proceed.
# Decode legacy bytes, rewrite UTF-8
raw = open("legacy.csv", "rb").read()
text = raw.decode("cp1252")  # Windows-1252
open("utf8.csv", "w", encoding="utf-8", newline="").write(text)

Excel and Encoding

"CSV (Comma delimited)" on some Excel builds is not UTF-8. Prefer "CSV UTF-8 (Comma delimited)" when available, or convert via Excel to CSV tools that emit UTF-8 explicitly.

Encoding in Databases and APIs

Postgres COPY should set ENCODING 'UTF8'. MySQL connections need matching character_set_client / database collation. HTTP APIs should send Content-Type with charset=utf-8 for CSV downloads.

Real-World Examples

Encoding bugs in the wild.

CRM import rejects names

Accented names from a European ERP arrived as Windows-1252. Re-encoding to UTF-8 fixed the import on the first retry.

Header became \uFEFFid

A Node csv-parse job missed bom: true. Enabling BOM handling restored the id column map.

API consumers see gibberish

S3 object was UTF-8 but Content-Type omitted charset; a client defaulted to Latin-1. Declaring charset=utf-8 fixed downstream displays.

Common Mistakes

Easy to get wrong once—and forever in a pipeline.

  • Calling every non-UTF-8 file "ANSI" without checking the real code page.
  • Transcoding twice (double UTF-8).
  • Stripping BOM by deleting the first three characters of a non-BOM file.
  • Assuming Notepad’s default save is UTF-8 on older Windows.
  • Fixing display in Excel only and leaving the pipeline encoding wrong.

Best Practices

Standardize and document.

  • UTF-8 for all new CSV contracts.
  • Document BOM policy for Excel consumers.
  • Validate a non-ASCII sample row in QA.
  • Set encoding explicitly in loaders (never rely on locale guess).
  • Convert legacy files once, then keep UTF-8 as source of truth.

Why Use Convert CSV Online?

Convert CSV Online is free, browser-based, and requires no account for everyday conversions. Preview text in the Online CSV Editor, re-export Excel as UTF-8 CSV, and convert only after characters look right. Client-side workflows work on Windows, macOS, and Linux browsers.

Confirm glyphs before convert

If names look wrong in preview, encoding is wrong—stop and fix before JSON/SQL export.

Conclusion

File encoding is the difference between correct text and permanent corruption. Prefer UTF-8, understand BOM tradeoffs, and re-encode legacy Windows CSV files before they enter modern pipelines.

FAQ

What is file encoding?

Encoding is the mapping between bytes on disk and characters you read. UTF-8, Windows-1252, and UTF-16 are different maps.

Should I use UTF-8 for CSV?

Yes for new systems. It supports all Unicode characters and is the web and API default.

What does ANSI mean for CSV?

On Windows, "ANSI" usually means a legacy code page such as Windows-1252—not a single global standard.

What is a UTF-8 BOM?

A signature at the start of a UTF-8 file. Excel often likes it; some parsers need an option to ignore it.

How do I fix mojibake in a CSV?

Decode with the original encoding (often cp1252), then re-save as UTF-8. Do not guess repeatedly.

Does Excel save CSV as UTF-8?

Only if you choose a UTF-8 CSV export option. Classic "CSV (Comma delimited)" may use a legacy code page.

References

Convert your CSV in the browser

Preview, clean, and convert CSV files free with Convert CSV Online—no installation and no account required for everyday conversions.