Skip to content
CSVFixKit
File Formats • Technical Guide

UTF-8 vs UTF-8 with BOM: Which Should You Use for CSV Files?

By Himayat Ur Rehman (HK Smart Tools) • •

Quick Answer

A Byte Order Mark (BOM) is a 3-byte signature (0xEF 0xBB 0xBF) placed at the beginning of a UTF-8 file to signal encoding. While Excel requires a BOM to automatically display international characters without mojibake, automated SQL databases, Python parsers, and Unix CLI tools often break when encountering unexpected BOM prefixes.

Key Facts:

  • Standard UTF-8 needs no byte order indicator; Unicode standards do not mandate BOM in UTF-8.
  • Microsoft Excel on Windows defaults to ANSI without a BOM, causing accented characters to break.
  • PostgreSQL, MySQL, and Unix pipelines can mistake the BOM for a column header character (id).
  • CSVFixKit lets you add or strip the UTF-8 BOM with one click based on your pipeline requirements.

1. What Is a Byte Order Mark (BOM)?

In computer architecture, multi-byte encodings (like UTF-16 and UTF-32) can store bytes in either Little-Endian (least significant byte first) or Big-Endian (most significant byte first) order. To disambiguate byte ordering, the Unicode Consortium introduced the Byte Order Mark (BOM): a special code point, U+FEFF (Zero-Width No-Break Space), placed as the very first sequence of bytes in a file.

In UTF-8, however, bytes are always processed in a single, well-defined sequence from left to right. Because endianness does not exist in UTF-8, a byte order indicator is technically superfluous. When U+FEFF is serialized in UTF-8, it produces a specific 3-byte signature at the beginning of the binary stream:

Hexadecimal byte sequence: 0xEF 0xBB 0xBF

The Unicode Standard explicitly states that a BOM is neither required nor recommended for UTF-8. Despite this recommendation, the software industry remains split due to one major application: Microsoft Excel.

2. The Microsoft Excel Exception: Why BOM Still Matters

When you double-click a CSV file on a Windows PC, Windows launches Microsoft Excel. In many versions of Excel, if a CSV file begins with standard ASCII or UTF-8 characters without a BOM, Excel defaults to opening the file using your Windows system ANSI codepage (typically Windows-1252 in North America and Western Europe).

If your file contains international characters (such as München, São Paulo, or 日本語), opening a plain UTF-8 CSV without a BOM will cause Excel to misinterpret those bytes as Windows-1252, instantly producing mojibake (e.g. München).

However, if the file begins with the 3-byte signature 0xEF 0xBB 0xBF, Excel recognizes the signature, activates its UTF-8 decoder automatically, and renders all accented and non-Latin characters perfectly upon launch.

3. When the BOM Breaks Unix, Python, and SQL Loaders

While the BOM solves Excel's auto-detection limitation, it frequently wreaks havoc in server-side data pipelines, Linux tools, and SQL databases:

  • Corrupted First Column Header: Many parsers that do not expect a BOM read the 3 bytes as literal text prepended to the first header name. Instead of column id, the parser reads \ufeffid or id. When you query SELECT id FROM table, the database responds with "Column 'id' not found."
  • Python Script Errors: In Python, reading a BOM-encoded file with standard open(filename, 'r', encoding='utf-8') leaves \ufeff inside the first field. Developers must remember to specify encoding='utf-8-sig' to discard the BOM.
  • Unix Shell Scripts: Command-line tools such as awk, sed, and cut treat the first three bytes as normal characters, breaking regular expression matching on line 1.

4. Step-by-Step BOM Handling in Excel, Google Sheets, and LibreOffice

Managing Byte Order Marks across different office productivity software requires understanding each application's import and export mechanics:

A. Microsoft Excel (Add or Omit BOM on Export)

In modern versions of Microsoft Excel on Windows and macOS:

  1. To save a file with a UTF-8 BOM: Click File → Save As, and choose CSV UTF-8 (Comma delimited) (*.csv) from the file format dropdown. Excel automatically prefixes the file with the 3-byte BOM (0xEF 0xBB 0xBF).
  2. To save without a BOM: If you select standard CSV (Comma delimited) (*.csv), Excel exports using the local ANSI system codepage (Windows-1252), which strips the BOM but risks corrupting international non-ASCII characters into mojibake. If this happens to your records, read our technical breakdown on why CSV shows é (mojibake).
  3. To open a UTF-8 file cleanly without a BOM: Open a blank workbook, navigate to Data → From Text/CSV, and manually choose 65001 : Unicode (UTF-8) in the File Origin dropdown before clicking Load.

B. Google Sheets (Upload and Download)

Google Sheets provides seamless, modern Unicode handling:

  1. When uploading via File → Import → Upload, Google Sheets detects UTF-8 encodings automatically. If a BOM is present, Google Sheets silently strips the marker from header text, ensuring no hidden characters contaminate column names.
  2. When exporting via File → Download → Comma-separated values (.csv), Google Sheets outputs pure UTF-8 without a Byte Order Mark by default, producing clean, RFC 4180-compliant files optimal for web servers and databases.

C. LibreOffice Calc (Explicit Filter Options)

LibreOffice Calc offers complete manual control over BOM injection during export:

  1. Open your dataset in LibreOffice Calc.
  2. Click File → Save As..., choose Text CSV (.csv) as the file type, and make sure to check the box marked Edit filter settings.
  3. Click Save. The Export Text File dialog will appear.
  4. Select Unicode (UTF-8) in the Character set dropdown.
  5. Notice the checkbox labeled Save with BOM: check this box if you intend to distribute the file to Excel users on Windows, or uncheck it if you are deploying to Linux servers, PostgreSQL, or Python pandas workflows.

5. Comparison: Plain UTF-8 vs. UTF-8 with BOM

FactorStandard UTF-8 (No BOM)UTF-8 with BOM
First 3 BytesData starts immediately at byte 00xEF 0xBB 0xBF
RFC 4180 / W3C StandardFully compliant & recommendedPermitted, but discouraged for UTF-8
Excel Direct Double-ClickOften mangles accented characters in WindowsRenders accented text cleanly in Excel
Linux / Bash / CLI ToolsWorks seamlessly without modificationMay appear as  in output
SQL Database LoadersClean schema mapping for column 1Can cause "Unknown column '\ufeffcol'" errors

6. Managing the BOM Header in CSVFixKit

Because both choices have valid operational uses depending on who will open the file, CSVFixKit gives you total control:

  1. Automatic Detection: When you analyze a file, our engine checks the initial 4 bytes. If EF BB BF is present, CSVFixKit notes BOM presence in the file metadata.
  2. Header Protection: CSVFixKit strips the leading BOM from column 1 during parsing so that your first column name is never polluted by  or \ufeff.
  3. Flexible Export Options: When downloading your repaired file, CSVFixKit offers a dedicated export option:
    • UTF-8 (Default): Standard clean UTF-8 without BOM. Recommended for database imports, cloud storage, Python, and APIs.
    • UTF-8 with BOM: Adds the EF BB BF header. Choose this option if your primary workflow involves colleagues opening the CSV directly in Microsoft Excel.

7. Common Mistakes with Byte Order Marks

  • Assuming UTF-8 Always Needs a BOM: Many developers add BOMs indiscriminately because Excel requires them. However, RFC 3629 explicitly recommends against using BOMs in UTF-8. In server-side environments, adding a BOM often breaks JSON parsers, Linux command line utilities (awk, cut), and automated database loaders.
  • Not Stripping BOM in Python or Node.js Ingestion: In Python, reading a file with open(filename, encoding='utf-8') leaves the BOM character intact in the first column name (e.g. \ufeffid). Developers must specify encoding='utf-8-sig' to cleanly strip the BOM on read.
  • Double BOM Injection: Concatenating multiple CSV files that each contain a BOM produces orphan BOM characters in the middle of the merged file, throwing fatal parser exceptions on row boundaries. When merging datasets from multiple departments, ensure you also remove duplicate rows from CSV safely to avoid repeat entries.

Frequently Asked Questions

What happens if I upload a CSV with a BOM to PostgreSQL or MySQL?

PostgreSQL and MySQL bulk loaders (like \copy or LOAD DATA INFILE) treat the 3-byte BOM as literal data attached to the first column name. Your first database header will be read as id instead of id, causing "column does not exist" query exceptions.

Does Google Sheets require a BOM to open UTF-8 CSVs correctly?

No. Google Sheets natively inspects character encoding using standard UTF-8 decoders and handles non-BOM files with accented characters seamlessly without requiring an explicit BOM signature.

How do I add or strip a BOM using CSVFixKit?

When downloading your repaired file from CSVFixKit, you can select whether to preserve the original BOM state, force UTF-8 with BOM (recommended for legacy Excel users), or strip the BOM (recommended for automated server pipelines).

Authoritative Standards & Verified Sources

CSVFixKit relies on standardized file specifications, encoding algorithms, and Unicode Consortium documentation:

Why CSV Shows é (Mojibake)

Fix encoding mismatches and corrupted accented characters.

Fix CSV Import Errors

Debug column count mismatches, broken quotes, and delimiter errors.

Remove Duplicate Rows Safely

Safely deduplicate records without losing valid transactions.