What is a byte order mark (BOM)?

Ever seen a mysterious “” at the start of a file, or an unexplained blank character breaking your JSON? That's often a Byte Order Mark — an invisible signal about the file's encoding.

What it does

The BOM is code point U+FEFF placed at the very start of a file. In UTF-16/UTF-32 it indicates byte order (big- vs little-endian). In UTF-8 it's unnecessary for byte order but is sometimes added as an encoding “signature.”

When it causes trouble

  • A UTF-8 BOM can break JSON parsers, shell scripts (shebang lines), and CSV imports.
  • It can render as a stray character or blank at the top of output.
  • Concatenating BOM-prefixed files scatters BOMs through the middle of text.

Best practice

For UTF-8, prefer no BOM on the web and in config/data files. Configure your editor to save UTF-8 without a BOM. Strip a leading U+FEFF when reading files that might contain one.

Frequently asked questions

Should UTF-8 files have a BOM?

Usually no — a UTF-8 BOM is optional and often causes problems in JSON, scripts and the web. Save without it.

What is U+FEFF?

The Byte Order Mark / zero-width no-break space; at the start of a file it signals encoding/byte order.