b2KIT

BOM (Byte Order Mark) Tool

Detect, add, or remove UTF-8/UTF-16 BOM from text files to fix encoding issues.

Tested tool guide Tested browser tools Checked August 15, 2026

What BOM (Byte Order Mark) Tool does, with a checked example

This tool inspects a file's leading bytes to tell you whether it starts with a byte order mark, then lets you add or strip one. A BOM is a short byte sequence - EF BB BF for UTF-8, FE FF or FF FE for UTF-16 - that some editors write automatically to signal encoding and byte order. The surprise: a UTF-8 BOM is legal but optional, and plenty of parsers (shell scripts, JSON readers, some CSV importers) choke on it or render it as a stray character even though the file looks completely normal when opened in a text editor.

Worked example

A concrete input and expected output from the current implementation.

Input

Hello  (save as UTF-8, BOM: Add)

Expected output

EF BB BF 48 65 6C 6C 6F

The tool prepends the 3-byte UTF-8 BOM signature (EF BB BF) to the existing UTF-8 bytes of "Hello" (48 65 6C 6C 6F); the visible characters are unchanged, only the marker is added.

How the result is produced

1

Detecting a BOM

The tool reads the first two or three bytes of the input and compares them against the known signatures: EF BB BF for UTF-8, FE FF for UTF-16 big-endian, FF FE for UTF-16 little-endian. It reports which marker, if any, is present without decoding or modifying the rest of the content.

2

Adding or removing

Adding a BOM prepends the matching byte sequence directly in front of the text's already-encoded bytes. Removing a BOM strips exactly those leading bytes and leaves everything after them untouched. Neither operation re-encodes or converts characters - it only edits the marker.

Good uses

  • A CSV opened in Excel shows garbled accented characters until a UTF-8 BOM is added so Excel recognizes it as UTF-8
  • A build script or JSON parser throws an unexpected-character error on the first line, traced to a leading BOM that needs removing
  • Comparing two supposedly identical text files where a byte-level diff or hash mismatch turns out to be caused by one file carrying a BOM and the other not

Limits and checks

  • A UTF-8 BOM is invisible in most editors, so 'my file looks fine but the tool flags a BOM' is expected, not a bug
  • Removing a BOM from a UTF-16 file without also converting the encoding can leave the text unreadable, since UTF-16 depends on the BOM or an external declaration to establish byte order
  • Some formats forbid BOMs outright (RFC 8259 says JSON should not have one), so a 'BOM detected' result on such a file usually means the file needs the BOM removed, not that the tool found an error

Common questions

Does adding a BOM change the actual text in my file?

No. It only prepends two or three marker bytes before your existing encoded text; the characters themselves are untouched. That said, some strict parsers, including many JSON parsers, will error on the extra bytes even though nothing about your content changed.

Will removing the BOM fix mojibake like 'é' showing instead of 'é'?

No. That kind of garbling comes from a file being saved in one encoding and read in another, which is a separate problem from a BOM marker. Adding or removing a BOM does not re-encode or repair already-corrupted character data.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools