UTF-8 Decode
Decode UTF-8 byte escapes and repair garbled (mojibake) text.
UTF-8 Decode – Decode Byte Escapes and Fix Garbled Text
This tool solves the two most common UTF-8 problems in one place. Decode byte escapes turns sequences like Caf\xC3\xA9 or %E2%82%AC back into readable characters. Fix garbled text (mojibake) repairs strings like Café costs €5 that were decoded with the wrong encoding and restores Café costs €5.
Decode byte escapes
Programs often print UTF-8 bytes instead of characters: Python shows b'Caf\xc3\xa9', URLs contain %C3%A9, Git and some shells print file names as \303\251, and log files may contain raw hex. The decoder accepts all of these notations – even mixed together and surrounded by normal text – collects the bytes, and decodes them as UTF-8. Multi-byte characters are joined correctly, so \xE2\x82\xAC becomes one € rather than three odd symbols. A plain list of hex or decimal bytes such as E2 82 AC works as well.
Fix garbled text (mojibake)
Mojibake happens when UTF-8 bytes are read as Windows-1252 or Latin-1. Each byte of a multi-byte character becomes its own character, so é (bytes C3 A9) turns into é and ’ (bytes E2 80 99) turns into ’. The fix reverses the mistake: it converts each character back to its original byte using the Windows-1252 table, then decodes the bytes as UTF-8. Typical sources are:
- CSV files saved as UTF-8 and opened in Excel with the default ANSI encoding.
- MySQL tables with a
latin1charset that store UTF-8 data. - Emails or web pages with a missing or wrong
charsetheader. - Copying text between applications that assume different encodings.
Tips
- Recognising the pattern helps:
Ãfollowed by another character almost always means a two-byte UTF-8 letter, andâ€a three-byte punctuation mark such as a dash or smart quote. - If only part of a document is garbled, paste just that part – correct non-Latin characters elsewhere will stop the repair.
- To prevent the problem, save and open files explicitly as UTF-8 and declare
<meta charset="utf-8">in HTML.
To see which bytes a character should have, use the UTF-8 Converter; for hex dumps, try Hex to UTF-8.
Frequently Asked Questions
What is mojibake?
Mojibake (Japanese for 'character transformation') is the garbled text you get when bytes are decoded with the wrong character encoding. The most common case on the web is UTF-8 text read as Windows-1252 or Latin-1: 'é' becomes 'é', '€' becomes '€', and a curly apostrophe becomes '’'.
Why does Fix garbled text say my text doesn't look like mojibake?
The repair works by turning every character back into the single byte it came from and decoding those bytes as UTF-8. If the text contains a character that can't come from a single Windows-1252 byte – for example a correct 'ş', a Chinese character, or an emoji – or if the resulting bytes aren't valid UTF-8, the text was not double-encoded in the usual way and is left unchanged.
What if the text was garbled twice?
Run the fix again on the output. Text that went through two wrong conversions, such as 'é' for 'é', needs one repair per conversion. Stop when the result reads correctly or the tool reports that the text no longer looks like mojibake.