Charset Detector: Detect File Encoding & Fix Garbled Text
Charset detector online: detect the real encoding of garbled text and files, then fix mojibake with one-click re-encoding.
Updated 2026-08-26
Related Tools
Base64 Encoder/Decoder: Encode & Decode Text Online
HTML Entity Encoder: Escape Special Characters Online
URL Encoder/Decoder: Percent Encoding & Decoding Online
ASCII Converter: Encode, Decode & View ASCII Table
Text to Binary Converter: Encode & Decode Binary Online
Hex to Text Converter: Encode & Decode Hexadecimal Online
Features
- Open or drag in any text file (.txt, .csv, .json, .log, .xml) and see its real encoding ranked by confidence
- Instant BOM detection: UTF-8 (EF BB BF), UTF-16 LE (FF FE) and UTF-16 BE (FE FF) are identified with certainty
- Strict UTF-8 validation with a fatal-error decoder: invalid byte sequences rule UTF-8 out instead of guessing
- GBK / GB18030 heuristic scoring: double-byte validity plus common hanzi-zone frequency catches Chinese files that fake-validate as UTF-8
- Confidence-ranked candidate list: each encoding shows a score bar, so you can see why UTF-8, GBK and UTF-16 compare the way they do
- Live decoded preview: the top candidate is decoded on the spot, so you can verify the text before converting
- One-click recode to UTF-8: save a corrected copy that keeps the original filename and extension
- Copy the decoded text to the clipboard for instant reuse elsewhere
- Pasted-text mojibake checker: recognizes classic 锟斤拷, é-style and 测试-style garbage and names the misread that caused it
- Honest about limits: tells you when pasted text has already lost its bytes, and only a real file can be repaired
- Built for common Chinese pain points: Notepad ANSI (GBK) files, Windows-exported CSVs, and misidentified downloads
How to Use
- 1Drag a file onto the dashed area, or click it to browse. Detection runs automatically; there is no Detect button in file mode.
- 2Read the candidate list: the top entry is the best guess, and each encoding shows a confidence bar and percentage.
- 3Check the decoded preview: proper Chinese or English text confirms the chosen encoding is right.
- 4Click 'Recode to UTF-8 & save' to save a corrected copy that keeps the original filename.
- 5Fix the classic Notepad problem: a file saved as ANSI (which for Chinese is GBK) opens as garbage. Load it here, pick GBK, and save the UTF-8 version.
- 6Handle Windows-exported CSVs that open fine in Excel but as mojibake everywhere else; the file is almost always GBK; one recode fixes it for all tools.
- 7Not sure what a downloaded file really is? Run detection; the scores show which encodings the bytes actually match.
- 8Switch to the text tab to paste a garbled snippet and learn which misread happened (GBK as UTF-8, UTF-8 as Latin-1, UTF-8 as GBK).
- 9Remember the honest rule: pasted garbled text has lost its bytes; the text tab diagnoses, only the file tab truly fixes.
- 10Keep UTF-16 BOMs when your editor offers them; future detection becomes instant and unambiguous.
Frequently Asked Questions
Why does my Chinese text show as garbled characters?
Garbled text happens when bytes are written with one encoding but read with another. The classic case: a file saved as GBK (the old Windows/Notepad 'ANSI' default for Chinese) is opened as UTF-8, or a UTF-8 file is opened as GBK. The characters look like random symbols, but the bytes are intact, which is why a real file can usually be fixed.
Why can't you recover my pasted garbled text?
Because pasting gives us characters, not bytes. Once the bytes were decoded with the wrong encoding, the original byte values are gone; many different byte sequences can produce the same garbled characters, so a reverse mapping is impossible. The text tab can tell you what went wrong, but only the file tab (which reads the original bytes) can truly repair the text.
How do you tell GBK from UTF-8?
UTF-8 is validated strictly: any invalid byte sequence fails it outright. GBK uses double-byte pairs in the ranges 0x81-0xFE plus 0x40-0xFE, so the detector scores how many bytes form legal GBK pairs and how many fall in the common hanzi zone (0xB0-0xF7). Chinese GBK files are usually invalid UTF-8, which is the strongest signal.
Which encodings does the tool support?
Detection covers UTF-8 (with or without BOM), UTF-16 LE/BE, GBK/GB18030, and Windows-1252. Recoding uses the encodings your browser's TextDecoder supports, which includes all of these. Other legacy encodings (Big5, Shift_JIS, and so on) are not detected.
Is the detection always correct?
No detector is 100% reliable for files without a BOM. Very short files and pure-ASCII files carry almost no encoding information, so their confidence stays modest. Long Chinese content gives strong signals, and files with a BOM are identified with certainty. That is why every result shows a confidence score instead of a single claim.
What is a BOM?
A byte order mark is a few bytes at the start of a file that declare its encoding: EF BB BF means UTF-8, FF FE means UTF-16 LE, FE FF means UTF-16 BE. Files with a BOM are detected instantly and unambiguously. When your editor asks, saving with a BOM is usually the safer choice.
What is '锟斤拷'?
It is the most famous Chinese mojibake. When GBK bytes are decoded as UTF-8, every broken pair becomes U+FFFD (�); if that text is then saved and read as GBK again, the U+FFFD characters turn into 锟斤拷. Seeing it means the bytes went through two wrong conversions; the information is already damaged and cannot be fully restored.
Can I convert multiple files at once?
No. This tool processes one file at a time. For batch conversion, run a small script with iconv or Python once you know the source encoding (the FAQ entry on GBK vs UTF-8 explains how to confirm it).
Will the recoded file lose anything?
When detection is correct, GBK → UTF-8 is lossless: every Chinese character maps exactly once. The exception is already-corrupted content like 锟斤拷, where the damage happened earlier and no tool can invent the missing information. Rare GB18030 extension characters convert cleanly to UTF-8 as well.
Will this fix garbled Chinese in Excel CSV files?
In most cases, yes. A CSV exported from Chinese Windows Excel is usually GBK, so other programs display it as mojibake. Drag the .csv file into the tool, confirm the GBK candidate, click 'Recode to UTF-8 & save', then open the saved copy; Excel, Numbers, and editors will all show it correctly. The tool keeps the original file untouched.
What should I do when the confidence is low or the preview looks wrong?
Try the next candidate in the ranked list; for example, if GBK scores just below UTF-8 for a short Chinese file, check the decoded preview under GBK before recoding. Short, pure-ASCII, or already-corrupted files carry little encoding information, so no detector can be certain; the preview is your verification step, and you only save after it looks right.
Why is my text still garbled after converting to UTF-8?
Usually it means the wrong source encoding was chosen: the file was decoded with the wrong charset, and the recoded copy keeps the same misread bytes. Reload the original file, try the next candidate in the ranked list, and only save after the decoded preview shows proper text. If every candidate looks wrong, the bytes were already corrupted before conversion; text that was pasted instead of opened as a file has lost its original bytes and cannot be fully restored.
Can you handle UTF-16 files?
Yes. Files with a UTF-16 BOM (what Notepad produces) are detected with certainty. BOM-less UTF-16 is detected by zero-byte position heuristics: reliable for ASCII-heavy text, but pure Chinese UTF-16 without a BOM is genuinely ambiguous and scores lower.
Can this tool damage my original file?
No. Your file is opened read-only and never modified; the tool only creates a new file for you to save. Keep the original until you have verified the recoded copy.
Why does my result differ from Mozilla's universal charset detector?
The two tools use different methods. Mozilla's universal detector (used by Firefox and many libraries) applies statistical n-gram models trained on large corpora; this tool uses strict UTF-8 validation, GBK/GB18030 double-byte scoring, BOM detection, and Windows-1252 heuristics. For files with a BOM, both agree with certainty. For short, ASCII-only, or genuinely ambiguous files the two can disagree, and no heuristic method is provably correct in those cases. Check the confidence bars and the decoded preview instead of trusting any single answer.