Home › Developer Tools › Text Encoding Converter

Text Encoding Converter

Open a text file to detect its character encoding, preview it correctly, and save it again as UTF-8, UTF-16, Windows-1252 or ISO-8859-1 with the line endings you choose. Files never leave your browser.

1. Source

2. Target

Advertisement

How to use the Text Encoding Converter

  1. Open a file (or switch to Paste text). The detected encoding, BOM and line endings appear immediately.
  2. Check the preview. If accented letters look wrong (for example é instead of é), pick a different source encoding from the list.
  3. Choose the target encoding, whether to add a BOM and which line endings to use.
  4. Press Convert and review the result. Characters that the target encoding cannot store are listed with their line numbers.
  5. Download the converted file.

How encodings store the same text

The word café uses four characters, but each encoding writes them as different bytes. Only the é changes in the 8-bit encodings; UTF-16 uses two bytes for every character.

EncodingBytes for "café" (hex)Size
UTF-863 61 66 C3 A95 bytes
UTF-8 with BOMEF BB BF 63 61 66 C3 A98 bytes
UTF-16 LE with BOMFF FE 63 00 61 00 66 00 E9 0010 bytes
UTF-16 BE with BOMFE FF 00 63 00 61 00 66 00 E910 bytes
Windows-1252 / ISO-8859-163 61 66 E94 bytes

This is why the wrong source encoding produces garbage: reading the UTF-8 bytes C3 A9 as Windows-1252 shows two characters, é, and reading the single Windows-1252 byte E9 as UTF-8 is invalid and shows �.

How detection works

  1. Byte order mark. A file starting with EF BB BF is UTF-8, FF FE is UTF-16 LE and FE FF is UTF-16 BE (four-byte marks indicate UTF-32). This is certain.
  2. UTF-16 without a BOM. English or code written in UTF-16 has a zero byte in every other position, which reveals the byte order.
  3. UTF-8 validation. UTF-8 multi-byte sequences follow strict rules. Text with accented letters that passes this check is almost certainly UTF-8, because legacy text rarely forms valid sequences by accident.
  4. Legacy fallback. Anything else is treated as Windows-1252, the most common 8-bit encoding. If the preview shows wrong letters, choose the right code page, such as Windows-1251 for Russian or Windows-1250 for Polish and Czech.

Common conversions

TaskSourceTarget settings
Fix accents in an old CSV or subtitle (.srt) fileWindows-1252UTF-8, no BOM
Make Excel open a CSV with accents correctlyUTF-8UTF-8 with BOM, CRLF
Remove a BOM that breaks a PHP, JSON or shell fileUTF-8 with BOMUTF-8, BOM unticked
Read a Windows "Unicode" .txt exportUTF-16 LEUTF-8, LF
Feed a legacy system that only accepts ANSIUTF-8Windows-1252 (check the list of unmappable characters)

Frequently asked questions

How do I convert a file to UTF-8?

Open the file, check that the preview shows the text correctly, choose UTF-8 as the target and press Convert, then Download. If the preview shows odd characters, change the source encoding first, because the conversion can only be as correct as the decoding.

Should I save UTF-8 with or without a BOM?

Without a BOM for almost everything: web pages, source code, JSON, CSV for most tools and Linux or macOS programs. Add a BOM mainly when Microsoft Excel must open a CSV file with accented characters correctly, or for some older Windows programs.

Why do I see characters like é or ’ in my text?

That is mojibake: UTF-8 bytes being read as Windows-1252. For example é is stored in UTF-8 as two bytes, C3 A9, which Windows-1252 shows as é. Select UTF-8 as the source encoding to read the file correctly.

Can encoding be detected with 100% certainty?

Only when the file has a byte order mark or contains non-ASCII text that is valid UTF-8. Legacy 8-bit encodings such as Windows-1252, Windows-1251 and ISO-8859-2 use the same bytes for different letters, so the tool makes a best guess and lets you pick another encoding if the preview looks wrong.

What is the difference between Windows-1252 and ISO-8859-1?

They are identical except for bytes 0x80 to 0x9F. Windows-1252 uses them for printable characters such as €, curly quotes and the long dash, while ISO-8859-1 reserves them for control codes. Text often labelled ISO-8859-1 is really Windows-1252.

What happens to characters the target encoding cannot store?

Windows-1252 and ISO-8859-1 can store only 256 characters. Anything else, such as emoji, Chinese or Polish letters like ł, is replaced by a question mark, an HTML numeric entity or removed, depending on your choice, and each one is listed so nothing is lost silently. UTF-8 and UTF-16 can store every character.

Related tools