TextyConverterbeta
⌘K

Strip BOM

Remove the Unicode Byte-Order Mark (U+FEFF) from the start of a string. Browser-only.

0 characters
0 characters

About Strip BOM

A Byte-Order Mark (BOM, U+FEFF) is an invisible character that some editors and tools — Windows Notepad, older Excel versions, certain serialization libraries — prepend to text files. While harmless when consumed by another BOM-aware tool, it can break JSON parsers, shell scripts, and PHP files that need to start with their first real character. This tool removes the BOM from the start of your input, and also any stray U+FEFFs in the middle.

When to use it

  • Cleaning up a JSON file that throws 'Unexpected token' on its very first character
  • Removing the leading byte that breaks PHP files saved by Notepad
  • Sanitizing CSV exports from Excel that prepend a BOM
  • Preparing text for systems that mishandle U+FEFF in the middle of a string

How it works

All occurrences of U+FEFF are replaced with an empty string. The character is invisible in most editors, so a quick visual inspection won't show whether it was present — only the byte count will change.

Examples

BOM removed from the start of JSON
{"hello":"world"}
{"hello":"world"}

Frequently asked questions

Is the BOM visible?
No. U+FEFF renders as zero-width, so most editors don't show anything. The clue is usually that the file appears to start with a normal character but a parser complains about an unexpected one.
Should I always strip BOMs?
For UTF-8 text consumed by web servers and parsers, yes — it almost always causes problems. For UTF-16 files where the BOM signals endianness, do not strip it.
Does it remove all instances or just the first?
All instances. While only the leading BOM is the common offender, stray ones in the middle of a string (introduced by sloppy concatenation) cause similar problems.
How can I tell if my file has a BOM?
Open the file in a hex viewer and look for EF BB BF at the start (UTF-8 BOM) or FE FF / FF FE (UTF-16 BOM). Alternatively, paste the start of the file here — the BOM will be visible in the character count difference between input and output.

Related tools