1001Ferramentas
🧹 Utilities

Strip BOM

Remove the Byte Order Mark (\uFEFF) from pasted text. Fixes common issues with Excel-generated CSVs.

BOM detectado: não

The invisible character at the start of a file

BOM stands for byte order mark, an optional marker at the start of a file that signals its encoding. In UTF-16 it does a real job, indicating byte order. In UTF-8 it is unnecessary, yet Notepad and various Microsoft tools add it anyway, writing the three bytes EF BB BF before the first real character.

The damage is always the same: an invisible character where nothing should be. In PHP, output before a header triggers "headers already sent". In CSV, the first header column gets junk in its name and the import cannot find the field. In JSON, the parser rejects the entire file. In a shell script, the shebang line stops being recognised. Paste the text here and the page reports whether a BOM was present and hands back the content without it.

Detection looks at the first character and checks for U+FEFF. Worth knowing: the browser sometimes strips the marker during paste, which makes the page report none even for content that had a BOM on disk — to check the file itself, use hexdump -C file | head -1 and look at the first three bytes. To save without the marker, virtually every editor offers a "UTF-8 without BOM" encoding option.

Frequently asked questions

Is a BOM in UTF-8 wrong?
It is not forbidden, but the Unicode specification itself discourages it: UTF-8 has no byte order ambiguity, so the marker carries no useful information. The consensus in Unix environments is to write without it. The common exception is Excel, which handles accented CSV better when the file has the marker.
How do I strip the BOM from many files at once?
In a terminal: sed -i '1s/^\xEF\xBB\xBF//' *.csv removes it from the first line of each. To sweep a whole tree, combine it with find. It pays to check first with file *, which identifies the ones reported as "UTF-8 Unicode (with BOM) text".
My JSON fails at position 0 and I cannot see anything wrong. What causes it?
That is the classic symptom. Messages such as "Unexpected token in JSON at position 0" or a SyntaxError mentioning an odd blank character point at a BOM. The parser reads the marker as a stray character, because the JSON grammar does not allow for it.

Related Tools