Overview
Introduction
A file that looks completely normal when opened in a text editor can still fail to parse because of a single invisible character at the very start: the UTF-8 byte order mark. Excel is a especially common source of it when exporting CSV as "UTF-8 with BOM".
This tool checks for that leading marker and strips it, so the text is safe to feed into a parser that doesn't expect it.
What Is BOM Detector and Remover?
A BOM (byte order mark) detector and remover for pasted text: it checks whether the very first character is U+FEFF, reports the result, and offers the text with that leading character removed.
It runs entirely client-side as part of this site's String Tools collection, so nothing you paste is ever uploaded to a server.
How BOM Detector and Remover Works
The tool reads the character code of the first character in the input using `charCodeAt(0)` and compares it against 0xFEFF, the code point a UTF-8 BOM decodes to in JavaScript strings.
If a BOM is present, the output is the same text with that first character sliced off; if not, the output is identical to the input and the tool reports that no BOM was found.
When To Use BOM Detector and Remover
Use it right after pasting text copied from a file that might have been saved as "UTF-8 with BOM", especially CSV files exported from Excel, before feeding that text into a JSON or CSV parser.
It's a fast way to get the answer without opening a hex editor or writing a one-off script just to check for an invisible character.
Often used alongside CSV Encoding Detector and Unicode and Encoding Repair Tool.
Features
Advantages
- Checks for the BOM directly by character code, which is unambiguous and instant.
- Only strips a BOM at the very start of the text, leaving a stray U+FEFF elsewhere in the content untouched.
- Reports clearly whether a BOM was found at all, rather than always silently stripping the first character.
Limitations
- Works on already-decoded pasted text, so it can only detect a BOM that survived decoding as the character U+FEFF; it can't inspect a file's raw bytes directly (use the CSV Encoding Detector for that).
- Only handles the UTF-8 BOM case represented as U+FEFF in a JavaScript string; it doesn't distinguish between UTF-16 or UTF-32 BOMs, which a browser textarea wouldn't preserve as pasteable text anyway.
Examples
Best Practices & Notes
Best Practices
- Run this before pasting CSV or JSON text into a strict parser that fails on unexpected leading characters.
- When re-saving a file after editing, prefer saving as "UTF-8 without BOM" if your editor offers the choice, to avoid reintroducing the marker.
- If a file still misbehaves after stripping a BOM here, check for other invisible characters (like non-breaking spaces) that a BOM check alone won't catch.
Developer Notes
Detection is `input.charCodeAt(0) === 0xFEFF`; removal is `input.slice(1)` when that check passes, otherwise the input is returned unchanged. Deliberately text-based rather than file-upload-based to match the UX of most tools in this category; see the CSV Encoding Detector for raw-byte BOM detection (EF BB BF for UTF-8) on an uploaded file.
BOM Detector and Remover Use Cases
- Cleaning up a CSV export from Excel before importing it into a script or database that chokes on a leading BOM
- Fixing a JSON file that fails to parse because of an invisible character before the opening brace
- Verifying whether a mysterious parsing failure is caused by a byte order mark
Common Mistakes
- Assuming a parsing error means the content itself is invalid, when an invisible leading BOM is actually the culprit.
- Manually trying to delete the "first character" in a text editor that doesn't render the BOM visibly, and accidentally deleting a real character instead.
Tips
- If you're not sure whether your text has a BOM, just run it through this tool; a clean input passes through unchanged and reports no BOM found.
- Combine this with the Line Break Normalizer when cleaning up text pasted from Windows sources, since both issues (leftover BOM and CRLF line endings) often show up together.