Why extracted filenames turn to gibberish — and how to fix the encoding
Mojibake means the name bytes were decoded with the wrong code page. It is fixable if the bytes are intact; replacement characters mean they are not.
NoUpload engineering teamLast updated
Key facts
- ZIP stores names as raw bytes; a flag bit marks UTF-8, and readers otherwise fall back to CP437 or a legacy local code page.
- Mojibake is reversible while the original bytes survive; replacement characters mean the bytes were already lost.
- Re-creating the archive with UTF-8 names prevents the problem, and macOS may also add __MACOSX and .DS_Store entries.
A ZIP file full of été.jpg, 涓枃.txt or 譌・譛ャ隱.pdf is not corrupt. The files inside are almost certainly fine; it is the names that were decoded with the wrong character encoding.
This is the single most common “the archive is broken” report, and whether it can be fixed depends on one detail: whether the name bytes were preserved or already replaced.
Why a ZIP has this problem at all
The ZIP format was designed in 1989, before UTF-8 was the default for anything. File names are stored as raw bytes. A general-purpose flag bit (bit 11) says “these bytes are UTF-8”; if it is not set, readers have to guess.
The official guess is CP437, the old IBM PC character set. In practice, the tools that made the archive wrote whatever the local system used:
| Made on | Names likely encoded as |
|---|---|
| Windows, Western Europe | CP1252 (Windows-1252) |
| Windows, Japan | Shift-JIS (CP932) |
| Windows, China | GBK (CP936) |
| Windows, Russia | CP1251 |
| macOS / Linux, last decade | UTF-8 |
| Modern zip libraries | UTF-8, with bit 11 set |
If the reader guesses differently from the writer, every non-ASCII character becomes one or more wrong characters. ASCII names — report.pdf, IMG_1234.jpg — survive because ASCII is identical in all of these encodings. That is why a folder can have half-readable names.
Reading the symptom
The pattern tells you what happened:
| You see | Likely cause | Recoverable? |
|---|---|---|
café, été |
UTF-8 bytes read as CP1252 | Yes |
涓枃, 鏂囦欢 |
GBK bytes read as UTF-8 | Yes |
譌・譛ャ隱, ​ |
Shift-JIS read as UTF-8/CP1252 | Usually yes |
| (replacement character) | Bytes replaced during decoding | No |
The last row is the important one. A replacement character (``) means a decoder already gave up and substituted a placeholder. The original byte is gone from that string, so re-decoding it cannot bring the name back. The file contents are still fine — only the name is lost.
café is the classic UTF-8-as-Latin-1 case: é is two bytes in UTF-8 (C3 A9), and reading each byte as a CP1252 character produces à and ©. Reverse it by encoding the string as CP1252 and decoding as UTF-8.
Why the browser cannot always fix it for you
The unzip tool reads names with the ZIP library’s defaults: UTF-8 when the archive says so, CP437 otherwise. That is correct for modern archives, but it is a guess for legacy ones — and a browser tab has no reliable way to ask “which Windows code page was this made on?”.
A desktop extractor can offer an encoding setting because it can try candidates against the actual bytes. A web tool that silently tried encodings could rename files wrongly, which is worse than showing the bytes as they are. So the honest workflow is: extract with the right tool when the names matter, then re-create the archive in UTF-8.
Fixing it on the desktop
- The Unarchiver (macOS): Preferences → Archive formats → set the filename encoding per format, or let it auto-detect. It is the most forgiving option for old archives.
- 7-Zip (Windows): generally auto-detects legacy code pages.
7z x archive.zipfrom the command line, or right-click → Extract. - Keka (macOS): File → preferences → “Use filename encoding” lets you pick Shift-JIS, GBK and others.
- Info-ZIP
unzip(Linux):unzip -O sjis archive.zipon builds that include iconv support;-Ois not available everywhere.bsdtar -xuses a different path and sometimes does better. - Python:
zipfile.ZipFile(..., metadata_encoding='cp932')re-reads the central directory with the chosen code page. Useful for scripted recovery.
Once the names look right, re-zip them. Modern tools set the UTF-8 flag, and the problem does not recur.
The macOS extras are not corruption
An archive made on macOS often contains:
__MACOSX/— resource forks and Finder metadata..DS_Store— folder view settings.
Neither is part of your documents. Delete them after extraction; they are noise from the packaging, not evidence of damage. Some tools hide them automatically, which is why the file count can look different between extractors.
A related trap: Unicode normalisation
macOS historically stores names in decomposed form: é as e plus a combining accent. Windows and Linux usually use the composed form. The two look identical on screen but are different byte sequences, so:
- A file can appear twice after syncing between macOS and Windows.
- Searching for
cafémay misscafe\u0301. - A script comparing names byte-for-byte sees two different files.
Re-zipping on Linux or using a tool that normalises to NFC avoids it. This is a naming problem, not an archive bug, but it produces the same “why are there duplicates?” symptom.
Names are not secret
Worth repeating from the encryption guide: ZIP encryption protects file contents, not the list of names. An encrypted archive still reveals every path, size and timestamp. If the names themselves are sensitive, the container is the wrong shape.
Practical checklist
- Check whether the file contents open correctly. If they do, only names are affected.
- Look for the replacement character “”. If present, the name bytes are already lost; rename manually.
- If the pattern is reversible (
é,涓枃), extract with The Unarchiver, 7-Zip or Keka and choose the source encoding. - Re-zip the corrected files so the next person does not repeat the process.
- Prefer UTF-8 when creating archives, and avoid non-ASCII paths when the recipient’s tools are unknown.
The ZIP creator writes UTF-8 names, so archives made here open with the right names everywhere. The format comparison explains when a different container is a better fit.
Questions this guide answers
Why are the filenames in my ZIP archive garbled?
The archive stored names in a legacy code page such as Shift-JIS, GBK or Windows-1252 without marking them as UTF-8, and your extractor decoded them as something else. The file contents are usually unaffected.
Can garbled ZIP filenames be fixed?
Usually, if the text shows patterns like é or 涓枃: extract with a tool that lets you choose the source encoding, such as The Unarchiver, 7-Zip or Keka, then re-zip. If the names contain replacement characters, the original bytes are gone and only manual renaming helps.
How do I create a ZIP with correct non-English filenames?
Use a modern tool that writes UTF-8 names and sets the ZIP UTF-8 flag. The creator here does that, as do current versions of 7-Zip and macOS. Avoid re-zipping with very old Windows tools if the names are not ASCII.