Detect File Encoding
Find the character encoding of any text file: TXT, CSV, HTML, XML, JSON, SQL, SRT subtitles, log files and more. The detector checks for a byte order mark, validates UTF-8, looks for UTF-16 patterns and scores legacy code pages.
Find out whether a file is UTF-8, UTF-16, Windows-1252, Windows-1256 and more, preview it in any encoding, convert it to UTF-8 and repair garbled text (mojibake).
Select one to preview the file as that encoding.
The raw bytes at the start of your file. A BOM or a telltale pattern often shows up here.
Paste some text to start.
Which writing systems appear in your text, by number of letters.
Detection and conversion run entirely inside your browser. Your files and text are never uploaded, sent to a server or stored.
Drop a text file, or paste text that looks broken.
See the best encoding, its likelihood and a live preview.
Download clean UTF-8 or copy the repaired text.
Opened a file and found strange symbols like é, ’, question marks or black diamonds instead of readable text? Then you are looking at an encoding problem, and this free text encoding detector helps you solve it in seconds. Upload a file and the tool inspects its raw bytes to tell you whether it is UTF-8, UTF-8 with BOM, UTF-16, UTF-32, ASCII, Windows-1252, Windows-1251, Windows-1256 for Arabic and Urdu, ISO-8859, KOI8, Shift_JIS, GBK, Big5 or EUC-KR. You get a ranked list of possible encodings with a relative likelihood, a live preview in any encoding you pick, a hex view of the first bytes and a one click download that converts the file to clean UTF-8. A second mode repairs garbled text that you paste, a problem known as mojibake, by reversing the wrong decoding step. It works as a character encoding checker, a file encoding detector, a UTF-8 validator, a charset detector and an encoding converter in one page. There is no signup, no software to install and nothing is uploaded: your files are read locally by your browser, so private documents, CSV exports, subtitles and database dumps stay on your device.
Find the character encoding of any text file: TXT, CSV, HTML, XML, JSON, SQL, SRT subtitles, log files and more. The detector checks for a byte order mark, validates UTF-8, looks for UTF-16 patterns and scores legacy code pages.
Paste text such as café or “quotes†and the repair mode reverses the wrong decoding to bring back café and “quotes”. It even handles text that was encoded twice, and it works for Latin, Cyrillic, Arabic and other scripts.
Once the preview looks right, download the file as UTF-8, with or without a BOM. UTF-8 is the safest encoding for websites, databases, APIs, source code and sharing files between different systems and countries.
See at once whether your file starts with a UTF-8, UTF-16 or UTF-32 byte order mark. The BOM explains many mysterious problems, such as strange characters at the start of a CSV or a PHP script that outputs headers too early.
Legacy files in Windows-1256, Windows-1251, Shift_JIS, GBK, Big5 and EUC-KR are a common source of broken text. The preview lets you test several encodings until the real language appears.
Inspect the first bytes of the file in hexadecimal, together with its size, line endings, ASCII status and UTF-8 validity. These facts help developers and data engineers understand exactly what is inside a mysterious file.
Computers store everything as numbers, so every letter you type has to be turned into bytes when it is saved, and turned back into a letter when the file is opened. A text encoding, also called a character encoding or charset, is the rulebook for that translation. The letter A, the Urdu letter ب, the euro sign and an emoji all need an agreed number and an agreed way to write that number as bytes. If the program that writes the file and the program that reads it use different rulebooks, the numbers are translated into the wrong characters and you see garbled text.
In the early days each language area created its own encoding, which is why there are dozens of legacy code pages such as Windows-1252 for Western Europe, Windows-1251 for Cyrillic and Windows-1256 for Arabic. Unicode was created to give every character in every language one unique number, and UTF-8, UTF-16 and UTF-32 are different ways of storing those numbers as bytes. Today UTF-8 is used by the vast majority of web pages and is the recommended default for new files, but old files, exports from legacy software and data from older systems are still full of other encodings.
| Encoding | Covers | Bytes per character | Typical use |
|---|---|---|---|
| ASCII | English letters, digits and basic symbols (128 characters) | 1 | Plain English text, source code, configuration files |
| UTF-8 | All of Unicode | 1 to 4 | Websites, APIs, databases, modern files |
| UTF-16 (LE / BE) | All of Unicode | 2 or 4 | Windows internals, Java and .NET strings, some exports |
| UTF-32 (LE / BE) | All of Unicode | 4 | Rare, mostly in memory |
| Windows-1252 (Latin-1) | Western European languages | 1 | Old Windows documents, legacy CSV and HTML |
| Windows-1251 | Russian, Ukrainian, Bulgarian and other Cyrillic languages | 1 | Legacy Cyrillic files and databases |
| Windows-1256 | Arabic and many Urdu and Persian letters | 1 | Legacy Arabic and Urdu documents and exports |
| Shift_JIS, EUC-JP | Japanese | 1 or 2 | Older Japanese software and websites |
| GBK, Big5 | Simplified and Traditional Chinese | 1 or 2 | Older Chinese software and websites |
| EUC-KR | Korean | 1 or 2 | Older Korean software and websites |
The strange text that appears when a file is opened with the wrong encoding is called mojibake, a Japanese word that means "character transformation". It is one of the most common problems when you open CSV files from other countries, import old databases, read emails and web pages with a wrong charset, or copy text between systems. The pattern of the garbage is a clue: the same wrong step always produces the same kind of mess, so you can often tell the cause just by looking at it.
| What you see | What it should be | Likely cause |
|---|---|---|
| café, naïve | café, naïve | UTF-8 text opened as Windows-1252 or Latin-1 |
| ’ “ †| ’ “ ” | UTF-8 curly quotes and dashes read as Windows-1252 |
| Привет | Привет | UTF-8 Cyrillic read as Windows-1252 |
| السلام | Arabic or Urdu letters | UTF-8 Arabic script read as Windows-1252 |
| Black diamonds with question marks | The original letters | Invalid bytes replaced by U+FFFD, often a legacy file read as UTF-8 |
| Rows of question marks | Non-English text | Characters could not be converted when the file was saved, so the data is already lost |
| Letters with spaces or null symbols between them | Normal text | UTF-16 file read as ASCII or UTF-8 |
|  at the start of a file | Nothing (invisible) | UTF-8 BOM read as Windows-1252 |
An important detail: if the broken text contains question marks or the replacement diamond, the original information may already be gone, and no tool can restore it from the pasted text alone. In that case you should go back to the original file and open it again with the correct encoding, which is exactly what the file detector tab is for.
Finding the encoding of a file used to require command line tools or a programmer's text editor. With this online file encoding detector the process takes a few seconds.
Always trust your eyes in the preview. If the preview shows readable words in the language you expect, you have found the right encoding, whatever the percentage says.
Plain text files do not carry a label that says which encoding they use, so detectors rely on evidence in the bytes. The evidence comes in layers, from the most reliable to the least reliable. Knowing the layers also explains why a result is sometimes marked as uncertain.
The last layer is a best guess, not a proof. Many single byte encodings use the same bytes for different letters, so a short Russian text can be a perfectly reasonable Windows-1251 or KOI8-R document. That is why this tool shows several candidates and lets you verify the answer in a preview.
A byte order mark is a small signature at the start of a file. For UTF-16 and UTF-32 it tells the reader whether the bytes of each character are stored with the most significant byte first (big endian) or last (little endian). For UTF-8 the order of bytes does not change, so a BOM is optional and only serves as a hint that the file is UTF-8. Some programs add it, and some programs are confused by it.
| Encoding | BOM bytes (hex) | Notes |
|---|---|---|
| UTF-8 with BOM | EF BB BF | Helps older Excel recognize UTF-8 in CSV files, but can break scripts, JSON parsers and shell files |
| UTF-16 LE | FF FE | Common in files saved as "Unicode" by Windows programs |
| UTF-16 BE | FE FF | Used by some Java and Mac based tools |
| UTF-32 LE | FF FE 00 00 | Rare |
| UTF-32 BE | 00 00 FE FF | Rare |
If a web page, PHP file or configuration file behaves strangely, check it for a stray UTF-8 BOM. The invisible bytes at the start can be sent to the browser as content, can break the "headers already sent" rule in PHP and can add an unexpected character to the first value of a JSON or CSV file.
If you only have the broken text, for example from an email, a database field or a web page, switch to the "Fix garbled text" tab and paste it. The repair mode assumes that the text was originally UTF-8, that it was then wrongly read with a single byte encoding, and that the result was saved. It reverses the wrong step: it turns the strange characters back into the bytes they came from, using the candidate encoding as a map, and then reads those bytes correctly as UTF-8. The tool tries Windows-1252 first, then Cyrillic, Arabic, Central European, Greek, Turkish, Hebrew, KOI8-R and Mac Roman, and it repeats the process up to three times for text that was damaged more than once.
CSV files are the number one source of encoding questions. A CSV is just text, so it can be saved in any encoding, but Excel guesses the encoding when you double click the file, and the guess is often wrong. A UTF-8 CSV with names such as José, Müller or محمد can show up with broken letters, while a Windows-1252 CSV opens fine. The reverse problem also exists when a program expects UTF-8 and receives a Windows-1252 file.
On the web the encoding must be declared and used consistently from end to end: the file on the server, the HTTP header, the HTML meta tag, the database connection and the database tables. A single weak link is enough to produce garbled text. The most reliable setup is UTF-8 everywhere.
Languages that do not use the basic Latin alphabet suffer the most when encodings go wrong. Old Arabic and Urdu systems used Windows-1256 or other code pages, and files from those systems appear as unreadable symbols or question marks in a UTF-8 application. Hindi and other Indic languages have a history of custom fonts that look correct only with one particular font installed. Today the right solution is to store such text as UTF-8, which supports all of these scripts in one file and displays them correctly in browsers, phones and office programs.
| Problem | Likely cause | What to do |
|---|---|---|
| Detector says ASCII, but the text is not English | The file contains only 7-bit characters, so the non-English text is already damaged or replaced | Export again from the original source in UTF-8 |
| Two or more encodings have similar likelihood | Single byte encodings share many byte values | Select each one and judge the preview by eye |
| Preview shows many replacement characters | Wrong encoding chosen, or the file is binary | Try other candidates, or check that the file really is text |
| File contains many null bytes | UTF-16 or UTF-32 file, or a binary file | Check the UTF-16 candidates |
| Converted file still looks wrong in Excel | Excel did not recognize UTF-8 without a BOM | Tick "Add UTF-8 BOM" before downloading |
| Repair tab shows no suggestions | Text is not mojibake, or characters are already lost | Use the original file in the detect tab |
This text encoding detector works on Windows, Mac, Linux, Android and iPhone in any modern browser. Your file is read locally with the browser's own decoding functions, so nothing is uploaded and no one else can see it. Bookmark this page and use it whenever a file shows strange characters, when you need to know whether a file is UTF-8 or Windows-1252, when you have to convert a legacy file to UTF-8 or when you want to repair text that looks like mojibake.
Ready to try it? Drop your file above, or paste your garbled text in the repair tab, and see the real content appear. If you also need to clean spaces, convert line breaks or analyze characters, explore the other free text tools on our site.
Quick answers about finding a file's encoding, fixing garbled characters and converting to UTF-8.
Drop the file into the detector. The tool checks for a byte order mark, tests whether the bytes are valid UTF-8, looks for UTF-16 patterns and scores common legacy encodings. It shows the best match with a relative likelihood and lets you preview the file in any candidate encoding to confirm the answer by eye.
This is mojibake, caused by reading text with a different encoding than the one used to write it. Characters like é usually mean UTF-8 text was read as Windows-1252. Question marks or black diamonds can mean the original characters were lost or replaced. Use the "Fix garbled text" tab to try to reverse the wrong step.
UTF-8 and UTF-16 can both store every Unicode character, but UTF-8 uses one to four bytes and is the standard on the web, while UTF-16 uses two or four bytes. Windows-1252 is an older single byte encoding for Western European languages that can store only 256 characters. Only the Unicode encodings can mix many scripts in one file.
Upload the file, select the encoding whose preview shows correct text, and click Download as UTF-8. Tick the BOM option if the file must open correctly in older versions of Excel. For code, JSON and shell scripts it is better to leave the BOM out.
Not always. A BOM or a valid multi byte UTF-8 sequence gives strong evidence, but many single byte encodings use the same bytes for different letters, and a short text can fit several of them. That is why the tool shows a ranked list and a live preview, so you can confirm the right encoding by checking that the text is readable.
Often, yes. If the file is a legacy Windows-1256 or Windows-1251 file, upload it, select that encoding in the preview and download the UTF-8 version. If you only have pasted text that was UTF-8 read as Windows-1252, the repair tab can usually restore it. If the text already became question marks, the original characters are gone and you need the source file.
Your file is never uploaded. It is read and analyzed inside your browser and disappears when you close the page. The tool accepts files up to 50 MB, and for very large files it analyzes the first part of the file for speed. As a general habit, avoid handling highly sensitive data on any website you do not fully trust.
Merge, split, compress and convert files in seconds. Explore powerful free tools for all your everyday needs.
Explore All Tools →