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.
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
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.