Text Encoding Detector
Detect a text file's encoding (UTF-8, UTF-16, or Latin-1/Windows-1252) from its byte-order mark (BOM) and byte validity, or repair text that looks garbled (mojibake), like "é" instead of "é". Everything is processed in your browser.
How it works
- 'Detect a file's encoding' tab: select a text file, and the tool first looks for a byte-order mark (BOM) at the start.
- If there's no BOM, it tries to decode the bytes as strict UTF-8; if that fails, it flags the file as likely using a single-byte encoding such as Windows-1252 or ISO-8859-1.
- 'Fix garbled text' tab: paste text with odd characters (mojibake), and the tool rebuilds the original bytes assuming they were mistakenly decoded as Latin-1, then re-decodes them as UTF-8.
- If the reinterpretation produces readable text, it's shown as the fixed result along with a button to copy it.
Use cases
- Figure out why a .csv or .txt file shows odd symbols when opened in a particular program.
- Fix text copied from a database or API that displays accented letters as strange sequences ("á", "é", "ñ").
- Confirm whether a file has a BOM before processing it with a tool that doesn't handle BOMs well.
- Check the encoding of a file exported from an older system before importing it into a new one.
Use cases
- Figure out why a .csv or .txt file shows odd symbols when opened in a particular program.
- Fix text copied from a database or API that displays accented letters as strange sequences ("á", "é", "ñ").
- Confirm whether a file has a BOM before processing it with a tool that doesn't handle BOMs well.
- Check the encoding of a file exported from an older system before importing it into a new one.
Common mistakes
- Expecting the tool to identify any possible encoding with absolute certainty.Without a BOM, detection is heuristic: it relies on whether the bytes are valid UTF-8 or not. A file in another encoding can, by coincidence, also be valid UTF-8, so the confidence shown (high, medium, or low) is a guide, not an absolute guarantee.
- Pasting text with emoji or characters from other alphabets into the mojibake tab and expecting it to be fixed.Mojibake repair assumes each character represents one byte (0-255), as happens when UTF-8 gets mistakenly decoded as Latin-1. If the text already contains characters outside that range (emoji, for example), it doesn't fit that pattern, and the tool flags it instead of corrupting the text.
- Pasting text that's already correctly encoded and being surprised that 'nothing changed'.If the text is already correct, reinterpreting it as mistakenly-decoded UTF-8 either produces the same text or nonsense, and the tool flags this instead of altering text that didn't have the problem.
Frequently asked questions
It's the name for the garbled text that appears when a file is decoded with an encoding different from its actual one. The most common case on the web is UTF-8 text (which uses multiple bytes for accented letters) misinterpreted as Latin-1/Windows-1252 (which assumes one byte per character), turning 'é' into 'é'.
It only repairs the specific — and most common — case of UTF-8 decoded by mistake as Latin-1/Windows-1252. Other incorrect encoding combinations (for example, Shift-JIS misread as UTF-8) require different logic that this tool doesn't cover.
The BOM (byte-order mark) is an invisible sequence of bytes at the start of a file that explicitly declares its encoding (UTF-8, UTF-16 LE, or UTF-16 BE). When it's present, detection is essentially certain; when it's absent, the tool falls back on heuristics based on byte validity.
No. Both reading the file and analyzing bytes or repairing mojibake happen entirely in your browser. Nothing is sent to or stored on an external server.
Alternatives
In a terminal, commands like `file -i` (Linux/Mac) or tools like Notepad++ (Windows) can also detect or force a file's encoding. For the specific case of mojibake from UTF-8 mistakenly decoded as Latin-1, this tool fixes it in one click, with nothing to install and no file or text uploaded to any server.