Byte Order Mark U+FEFF
The byte order mark (U+FEFF) is an invisible character that breaks JSON, CSV, PHP and shell scripts. See why it appears and how to find and remove it.
Remove the Byte Order Mark from your text
Paste your text below. It stays in your browser; nothing is uploaded.
Other hidden characters too? Scan for all of them
- Codepoint
U+FEFF- Decimal
65279- HTML
- CSS
\FEFF- JS
\uFEFF- URL
%EF%BB%BF- UTF-8
EF BB BF- Category
Format (Cf)- Block
Arabic Presentation Forms-B
The byte order mark (BOM, U+FEFF) is an invisible character at the very beginning of a text file that signals the file's character encoding and byte order. The bugs it causes are hard to see: the file looks correct in every editor and the code has no syntax errors, but something still breaks.
Hit a JSON parse error, a PHP "headers already sent" warning, a shell script that won't run, or a CSV import that fails on the first column? Check for a BOM.
What BOM Actually Does
BOM has two legitimate jobs:
1. Byte Order Detection (UTF-16)
UTF-16 stores characters as 2-byte units, and those bytes can be ordered two ways: big-endian (most significant byte first) or little-endian (least significant byte first). The BOM tells software which one the file uses:
- FE FF (big-endian): the BOM character stored as-is.
- FF FE (little-endian): the BOM character with bytes reversed.
This is the original purpose of BOM. Without it, a UTF-16 reader has to guess.
2. UTF-8 Encoding Signature
UTF-8 has a fixed byte order, so there's nothing to detect. But some software, especially on Windows, writes the three bytes EF BB BF at the start of UTF-8 files as a "this is UTF-8" signature. This is where the trouble starts.
Why BOM Causes Bugs
A UTF-8 BOM puts three bytes (EF BB BF) before your content. Editors hide them. Software reading the raw bytes sees unexpected data first.
JSON
The JSON spec does not allow a BOM in transmitted JSON, and many parsers (including JavaScript's JSON.parse) reject it with a parse error.
PHP
PHP sends the BOM bytes as response body before your code runs, so you can't set headers, start sessions, or send redirects.
Shell Scripts
CSV Import
The first column header gets three extra invisible bytes. Column matching, header parsing, and data mapping fail silently or produce wrong results.
XML
Common Uses (When BOM Is Present)
- Windows Notepad. Notepad historically saved UTF-8 files with BOM by default, the biggest single source of BOM bugs.
- Microsoft Excel. Excel often adds a BOM when saving CSV files, which breaks imports in other software.
- Some IDEs and text editors. Older versions of various editors saved with BOM by default.
- File conversion tools. Converting between encodings can add a BOM.
- Copy-paste. Text copied from a BOM-prefixed file can carry the BOM along.
How to Detect BOM
In Our Tool
Paste your file contents into the Invisible Character Viewer on the homepage. It highlights the BOM at the start of the text with the label "BOM" and code point U+FEFF.
On the Command Line
In Code
How to Remove BOM
| Tool | Method |
|---|---|
| VS Code | Click encoding in status bar > "Save with Encoding" > "UTF-8" (not "UTF-8 with BOM") |
| Notepad++ | Encoding > Convert to UTF-8 |
| Sublime Text | File > Save with Encoding > UTF-8 |
| Vim | :set nobomb then :w |
Command line (GNU sed; gsed on macOS) | sed -i '1s/^\xEF\xBB\xBF//' filename |
| PowerShell | Read file, strip BOM, write back without BOM encoding |
| Python | Open with encoding='utf-8-sig', write with encoding='utf-8' |
| Git | Configure a custom clean filter in .gitattributes to strip BOM on commit |
How to Type
| Platform | Method |
|---|---|
| Any | You almost never need to type it. Editors add it on save. |
| HTML |  or  (but don't add a BOM to HTML). |
| JavaScript | in strings. |
| Linux | Ctrl+Shift+U, type FEFF, press Enter. |
Technical Details
- Unicode category: Cf (Format).
- Width: Zero. No visible glyph.
- Historical note: U+FEFF was originally both a byte order mark and a zero-width no-break space. Unicode 3.2 (2002) deprecated the inline use and introduced U+2060 (Word Joiner) to replace it.
- UTF-8 representation: EF BB BF (3 bytes).
- UTF-16BE representation: FE FF (2 bytes).
- UTF-16LE representation: FF FE (2 bytes).
- UTF-32BE representation: 00 00 FE FF (4 bytes).
- UTF-32LE representation: FF FE 00 00 (4 bytes).
Should You Ever Use BOM?
For UTF-16: Yes. It resolves the byte-order ambiguity.
For UTF-8: Almost never. The Unicode Consortium says: "Use of a BOM is neither required nor recommended for UTF-8." The exception is software that needs a BOM to identify UTF-8 (some older Windows tools). For web, development, and data exchange, use UTF-8 without BOM.
For new files: Save as UTF-8 without BOM. Most modern editors default to this, but check your settings.
The BOM Debugging Checklist
- Confirm it. Paste the file into our Invisible Character Viewer, or run
file filenameand look for "(with BOM)". - Check your editor's encoding. It should say "UTF-8", not "UTF-8 with BOM."
- Check every file in the chain. If you import a CSV exported from Excel, the BOM may be in the CSV, not your code.
- Check your
.gitattributes. Git has no built-in BOM stripping, but a custom clean filter there can strip it on commit. - Check
.envfiles. A BOM prepends three invisible bytes to the first variable name, so parsing fails silently. IfDATABASE_URLisn't recognized, the name may really be\xEF\xBB\xBFDATABASE_URL, which doesn't match.
Frequently Asked Questions
What is a byte order mark (BOM)?
A BOM (U+FEFF) is an invisible character at the very beginning of a text file that signals its character encoding and byte order. In UTF-8 it is the three bytes EF BB BF. In UTF-16 it shows whether the file is big-endian or little-endian.
Why does BOM cause bugs?
The BOM is invisible in most editors but is real data at the start of the file. JSON parsers, CSV importers, XML processors, shell interpreters, and PHP expect the file to start with content, so the extra bytes break parsing.
How do I remove a BOM from my file?
In VS Code: click the encoding in the status bar, choose 'Save with Encoding', then 'UTF-8' (without BOM). In Notepad++: Encoding > Convert to UTF-8. On the command line (GNU sed; use gsed on macOS): sed -i '1s/^\xEF\xBB\xBF//' filename. Our Invisible Character Viewer detects it.
Should I use UTF-8 with or without BOM?
Without BOM, in almost all cases. The Unicode Standard says a BOM is neither required nor recommended for UTF-8. It is mainly useful for UTF-16 and UTF-32 files whose byte order isn't declared another way. Most modern software assumes UTF-8, so a BOM is unnecessary and often harmful.
What is the difference between BOM and Word Joiner?
U+FEFF was originally both a byte order mark (at the start of files) and a zero-width no-break space (inline in text). Unicode 3.2 split these roles: U+FEFF should now be used only as a BOM, and U+2060 (Word Joiner) handles inline no-break behavior.
Related Characters
U+2060Zero-Width SpaceU+200BZero-Width Non-JoinerU+200CZero-Width JoinerU+200DLeft-to-Right MarkU+200ESoft HyphenU+00ADNeed to find every hidden character in your text, not just the Byte Order Mark?
Open the viewer