Understand CSV File Encodings

How CSV and TSV encodings such as UTF-8, UTF-8 with BOM, UTF-16 and Windows-1252 differ, what conversion changes, and how to keep data readable.

A CSV file is plain text, but plain text is always stored as bytes, and an encoding is the rule that maps those bytes to characters. The CSV format does not record which encoding was used. Every program that opens the file has to be told the encoding or guess it. Most garbled accents, stray symbols at the start of a header row and broken imports come from that guess going wrong. This guide explains the common encoding types, what converting between them actually changes, and how to judge whether a converted file will still mean the same thing and work where you need it.

Scope and evidence: no product tests, measurements or vendor documentation were supplied for this article. The explanations below rest on how the encodings are defined. Behavior in any specific spreadsheet, database or import tool is described only in general terms and should be confirmed with that tool's documentation or a small test file.

Is converting or re-saving a CSV in a different encoding right for your use?

For most new files, UTF-8 is the sensible default. It can represent every Unicode character, it is identical to ASCII for basic English letters, digits and punctuation, and many modern tools and programming libraries use it by default. The main tradeoff is that some older or locale-dependent software assumes a legacy single-byte encoding unless told otherwise, and may display UTF-8 text incorrectly. Some tools rely on a byte order mark (BOM) to recognize UTF-8, while others treat the BOM as unwanted data.

A legacy encoding such as Windows-1252 or ISO-8859-1 is preferable only when a specific receiving system requires it and all of your data fits inside it. If the file contains only basic ASCII characters, the choice barely matters: ASCII, UTF-8 without a BOM, Windows-1252 and ISO-8859-1 all store those characters as identical bytes. Only UTF-16 differs.

Avoid conversion when you cannot confirm the source encoding. Converting from a wrong assumption permanently bakes the misreading into the new file.

Common CSV encoding types compared

Encoding | Bytes per character | Matches ASCII for basic characters | Byte order mark | Typical situation
ASCII | 1 | Yes (it is ASCII) | None | Data limited to unaccented English letters, digits and basic punctuation
UTF-8 (no BOM) | 1 to 4 | Yes | None | Default for many modern tools, web systems and programming languages
UTF-8 with BOM | 1 to 4, plus 3-byte prefix EF BB BF | Yes, after the prefix | EF BB BF | Used to signal UTF-8 to software that otherwise guesses a legacy encoding
UTF-16 LE / UTF-16 BE | 2 or 4 | No | FF FE (LE) or FE FF (BE), usually present | Produced by some export options labeled simply as Unicode
Windows-1252 | 1 | Yes | None | Older Western European Windows software
ISO-8859-1 (Latin-1) | 1 | Yes | None | Older Western European systems; close to Windows-1252 but not identical
Shift_JIS, GB18030, Big5 and similar | 1 or more | Mostly | None | Legacy East Asian systems

Windows-1252 and ISO-8859-1 are often treated as interchangeable, but they differ in the byte range 80 to 9F. Windows-1252 uses that range for characters such as curly quotes, the euro sign and the em dash, whereas ISO-8859-1 assigns control codes there. A file that contains curly quotes and is labeled as the wrong one of the two will show those characters incorrectly.

What changing the encoding actually changes

Re-encoding changes the stored bytes, not the intended characters. A correct conversion from Windows-1252 to UTF-8 keeps every character the same and only rewrites how each one is represented on disk. The word café shows the difference:

Text: café

Windows-1252 / ISO-8859-1:  63 61 66 E9
UTF-8:                      63 61 66 C3 A9
UTF-8 with BOM:             EF BB BF 63 61 66 C3 A9
UTF-16 LE with BOM:         FF FE 63 00 61 00 66 00 E9 00

Problems appear when bytes are decoded with a different encoding than the one used to write them. The text then changes in meaning even though no one edited it:

UTF-8 bytes read as Windows-1252:
  63 61 66 C3 A9  ->  café

Windows-1252 bytes read as UTF-8:
  63 61 66 E9     ->  caf�   (E9 alone is not valid UTF-8)

UTF-8 with BOM read by a tool that ignores the BOM:
  EF BB BF 69 64  ->  id  (first header becomes "id" instead of "id")

These patterns are useful diagnostics. Sequences such as é, è or ’ usually mean UTF-8 was read as a single-byte legacy encoding. The replacement character � usually means legacy bytes were read as UTF-8. A mysterious first column name usually means a BOM was not recognized.

Encoding, delimiter, font and normalization are different things

  • Encoding: how characters are stored as bytes. It decides whether é survives the trip between programs.
  • Delimiter: the character that separates fields, such as a comma in CSV or a tab in TSV. Changing the delimiter is a structural change and is separate from the encoding, although both are often chosen in the same save dialog.
  • Font: how a program draws characters on screen. A font never changes the stored data. An empty box or blank square usually means the font lacks that character, not that the file is damaged, and the same file may display correctly with another font.
  • Unicode normalization: the same visible character can be stored in more than one way. For example, é can be a single code point (U+00E9) or an e followed by a combining acute accent (U+0301). Both look identical and both survive any UTF conversion, but they can fail exact-match searches, joins and duplicate checks against each other. Encoding conversion does not normalize text unless the tool explicitly says it does.

The word Unicode is also used loosely. In some export dialogs, an option labeled Unicode produces UTF-16 rather than UTF-8. Check the documentation or inspect the first bytes of the output before assuming which one you received.

When conversion loses data

Converting into UTF-8 or UTF-16 from any standard encoding is lossless when the source encoding is identified correctly. Converting out of Unicode into a legacy encoding is lossy whenever the data contains characters the target cannot represent, such as emoji, many non-Latin scripts or certain symbols. Depending on settings, tools may stop with an error, drop those characters or replace them with a question mark. Once replaced, the original characters cannot be recovered from the converted file, so keep the source file until the result has been checked.

Will the file stay readable and usable after sharing?

An encoding mismatch affects every downstream use of the data, not just how the file looks:

  • Opening and copying: if a program decodes the file with the wrong encoding, the garbled text is what gets copied, pasted or re-saved, and it spreads the error into other documents.
  • Search and matching: a name stored as café will not match a search for café, and lookups or database joins on that column will silently miss rows.
  • Accessibility: screen readers and other assistive technology read the decoded text. Mojibake is announced as a string of unrelated symbols or letters, and a header altered by an unrecognized BOM may be read with extra characters. No assistive technology was tested for this article; check the specific tools your readers use.
  • Structure: tools that scan for commas, tabs or line breaks byte by byte can misread UTF-16 files, where each of those characters takes two bytes. This can produce a single-column import or broken rows.
  • Editing: re-saving a misdecoded file in a text editor or spreadsheet writes the corruption back to disk, often in a new encoding, which makes the original harder to recover.

Whether a particular spreadsheet, database or web form handles UTF-8, a BOM or UTF-16 correctly depends on the product, its version, the operating system's regional settings and the import path used, such as double-clicking the file versus using an import wizard that lets you pick the encoding. One successful open on one machine does not prove the file will behave the same elsewhere. If the receiving system is known, consult its documentation for the encoding it expects. If it is not, include a sample of the trickiest characters in a small test file and open it there.

An ASCII-only version of the data is the most portable option when the recipient's software is unknown and the content allows it, for example identifiers, numeric data or English-only text. It is not a substitute for data whose meaning depends on accents or non-Latin scripts. Stripping é to e changes names, and transliteration can create collisions between values that were previously distinct.

Checking and converting encodings safely

Automatic detection is a guess. A file containing only ASCII is valid in many encodings at once, and some single-byte legacy encodings cannot be told apart from bytes alone. Confirm the encoding with whoever produced the file when possible. The commands below are common on Linux and macOS and illustrate the steps; output and option names can vary by version.

# Guess the encoding (a heuristic, not proof)
file -i data.csv

# Show the first bytes to spot a BOM (EF BB BF, FF FE or FE FF)
head -c 16 data.csv | xxd

# Convert from Windows-1252 to UTF-8, keeping the original
iconv -f WINDOWS-1252 -t UTF-8 data.csv > data-utf8.csv
# Python: read UTF-8 with or without a BOM; the BOM is removed if present
import csv
with open("data.csv", encoding="utf-8-sig", newline="") as f:
    rows = list(csv.reader(f))

# Fail loudly instead of silently replacing characters on output
with open("out.csv", "w", encoding="utf-8", newline="", errors="strict") as f:
    csv.writer(f).writerows(rows)
  • Keep the original file untouched until the converted copy is verified.
  • Identify the source encoding from the producer, documentation or byte inspection rather than a single detector result.
  • Pick the target encoding the receiving system documents. Use UTF-8 when there is no stated requirement.
  • Decide deliberately whether a BOM should be included, based on what the receiving tool expects.
  • Prefer strict error handling, so unsupported characters cause an error instead of being silently replaced.
  • Compare a few known rows before and after, especially names with accents, symbols, emoji and non-Latin text.
  • Check the header row for stray characters and confirm the column count is unchanged.
  • Open the result in the actual destination tool, not only in the tool that produced it.

Bottom line

An encoding change preserves meaning only when the source encoding is identified correctly and the target can represent every character in the data. UTF-8 meets the second condition for any text and is the safest general choice. A legacy encoding is justified only when a known destination requires it and the data fits. The byte order mark and UTF-16 are compatibility decisions to make for a specific destination, not defaults. Because behavior varies by product and setup, and this article includes no tool-specific test results, verify the converted file in the place it will actually be used.