UTF-8 BOM Tool
Detect, add, or remove the UTF-8 byte-order mark
UTF-8 BOM Tool — what it does
Detect whether a file starts with a UTF-8 byte-order mark, and add or remove it. The BOM is three invisible bytes at the very start of a file, and it is the reason a CSV opens with a strange character before the first header, or a script suddenly refuses to run.
Worked example
Two versions of a three-line staff export, one saved without a byte-order mark and one with it, each run through detection and both buttons.
| Input file | Detected | Button | Download |
|---|---|---|---|
| staff-export.csv (51 bytes, no BOM) | No UTF-8 BOM detected | Add UTF-8 BOM | bom-staff-export.csv, 54 bytes, BOM present |
| staff-export.csv (51 bytes, no BOM) | No UTF-8 BOM detected | Remove UTF-8 BOM | no-bom-staff-export.csv, 51 bytes, unchanged |
| export-with-bom.csv (54 bytes, BOM) | UTF-8 BOM present | Remove UTF-8 BOM | no-bom-export-with-bom.csv, 51 bytes, BOM gone |
| export-with-bom.csv (54 bytes, BOM) | UTF-8 BOM present | Add UTF-8 BOM | bom-export-with-bom.csv, 54 bytes, unchanged |
The BOM is exactly three bytes, so the sizes differ by 3; the text content is byte-for-byte identical in all four downloads.
When this tool helps
- Removing a BOM that is breaking a script, a config parser or a shell file.
- Adding a BOM so Excel opens a UTF-8 CSV with the correct encoding instead of mangling accents.
- Checking whether an unexplained parsing failure is caused by a BOM at all.
How to use it
- Choose the file.
- See whether a BOM is present.
- Add or remove the BOM as needed.
- Download the corrected file.
Accuracy, limits, and good practice
- Excel is the reason to add one: without a BOM it frequently reads a UTF-8 CSV as a legacy code page and destroys every accented character.
- Programming and configuration files should have no BOM — it appears as stray characters at the start and breaks shebang lines and JSON parsers.
- The BOM is invisible in every editor, which is exactly why it causes bugs that make no sense until you check for it.
Frequently asked questions
What is a byte-order mark?
A marker at the start of a file indicating its encoding. In UTF-8 it is unnecessary for byte order and functions purely as an encoding hint.
Should my files have one?
For CSV destined for Excel, usually yes. For code, configuration and JSON, no.
Why does my JSON fail to parse?
A BOM before the opening brace is not whitespace to a strict parser, so it rejects the document. Remove it and it parses.
What happens if I add a BOM to a file that already has one?
Nothing is added: the tool checks the first three bytes first, and if they are already EF BB BF it downloads the file unchanged, so you never get a double BOM; the download is still renamed with the bom- prefix. Removing from a file that has none works the same way and returns no-bom-<name> with identical content.
Does it recognise UTF-16 byte-order marks?
No. Only the UTF-8 sequence EF BB BF is detected. A UTF-16 file (starting FF FE or FE FF) is reported as having no BOM, and clicking Add would prepend a UTF-8 mark to it, producing a file no editor reads correctly. Convert such files to UTF-8 first.
Related tools on this site
- Multi-Hash File Calculator — Calculate SHA-1, SHA-256, SHA-384, and SHA-512 checksums
- UTM Link Builder — Build trackable campaign URLs with UTM source, medium, campaign, term, and content
- Directory Tree Generator — Select a folder and generate a downloadable text directory tree
Further reading: How Local Browser Tools Protect Your Files
Everything above runs inside this page. UTF-8 BOM Tool needs no account, no upload, and no server round trip — close the tab and nothing is left behind.
UTF-8 BOM 工具能做什麼
偵測檔案開頭是否有 UTF-8 位元組順序標記(BOM),並可新增或移除。BOM 是檔案最前面三個看不見的位元組,正是它讓 CSV 的第一個標題前多出怪字元,或讓腳本突然跑不起來。
實際範例
同一份三行員工名單的兩個版本,一份存檔時沒有位元組順序標記、一份有,各自跑過偵測與兩個按鈕。
| 來源檔案 | 偵測訊息 | 按鈕 | 下載 |
|---|---|---|---|
| staff-export.csv(51 位元組,無 BOM) | 未偵測到 UTF-8 BOM | 新增 UTF-8 BOM | bom-staff-export.csv,54 位元組,含 BOM |
| staff-export.csv(51 位元組,無 BOM) | 未偵測到 UTF-8 BOM | 移除 UTF-8 BOM | no-bom-staff-export.csv,51 位元組,內容不變 |
| export-with-bom.csv(54 位元組,含 BOM) | 已包含 UTF-8 BOM | 移除 UTF-8 BOM | no-bom-export-with-bom.csv,51 位元組,BOM 已移除 |
| export-with-bom.csv(54 位元組,含 BOM) | 已包含 UTF-8 BOM | 新增 UTF-8 BOM | bom-export-with-bom.csv,54 位元組,內容不變 |
BOM 剛好是三個位元組,所以大小差 3;四個下載檔的文字內容逐位元組完全相同。
什麼時候用得上
- 移除弄壞腳本、設定解析器或 shell 檔案的 BOM。
- 為 UTF-8 CSV 加上 BOM,讓 Excel 以正確編碼開啟而不會把重音字元弄壞。
- 確認莫名其妙的解析失敗,究竟是不是 BOM 造成的。
使用步驟
- 選擇檔案。
- 查看是否含有 BOM。
- 視需要新增或移除 BOM。
- 下載修正後的檔案。
精確度、限制與實務建議
- 要加 BOM 的理由就是 Excel:沒有 BOM 時它常把 UTF-8 CSV 當成舊編碼讀,把每個重音字元都毀掉。
- 程式與設定檔不該有 BOM——它會在開頭變成雜訊字元,弄壞 shebang 行與 JSON 解析器。
- BOM 在任何編輯器中都看不見,這正是它引發的錯誤在你想到要檢查它之前完全講不通的原因。
常見問題
什麼是位元組順序標記?
檔案開頭用來標示編碼的記號。在 UTF-8 中它對位元組順序並無必要,純粹作為編碼提示。
我的檔案該加嗎?
要給 Excel 的 CSV 通常要加;程式碼、設定檔與 JSON 則不要。
為什麼我的 JSON 解析失敗?
開頭大括號前的 BOM 對嚴格解析器而言不算空白,因此會被拒收。移除它就能正常解析。
對已經有 BOM 的檔案再按新增會怎樣?
不會再加:工具先檢查開頭三個位元組,若已是 EF BB BF 就原樣下載,不會變成雙重 BOM,只是檔名仍加上 bom- 前綴。對沒有 BOM 的檔案按「移除 UTF-8 BOM」也一樣,會得到內容相同的 no-bom-<檔名>。
能辨認 UTF-16 的位元組順序標記嗎?
不能。只偵測 UTF-8 的 EF BB BF。UTF-16 檔案(開頭 FF FE 或 FE FF)會被回報為沒有 BOM,若再按新增,會在前面多加一個 UTF-8 標記,變成任何編輯器都讀不對的檔案。這類檔案請先轉成 UTF-8。
本站相關工具
- 多演算法檔案雜湊 — 計算 SHA-1、SHA-256、SHA-384 與 SHA-512 校驗值
- UTM 行銷連結生成器 — 使用來源、媒介、活動、關鍵字和內容參數建立追蹤網址
- 資料夾目錄樹生成器 — 選擇資料夾並生成可下載的文字目錄樹
延伸閱讀: 本地瀏覽器工具如何保護你的檔案
以上步驟全部在這個頁面內完成,UTF-8 BOM 工具 不需要註冊、不上傳檔案、也不經過伺服器,關閉分頁後不會留下任何資料。