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.

Last updated:

1. Source

2. Target

Advertisement
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.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

Base64 Encoder DecoderEncode or decode Base64 text and files, and make data URIs.URL Encoder DecoderPercent-encode or decode URLs, query strings and form data.HTML Entity Encoder / DecoderEscape and unescape HTML entities, named or numeric.Binary TranslatorConvert text to binary, hex, octal and back.ASCII TableFull ASCII code chart 0–255 in decimal, hex, octal, binary and HTML, with search and copy.Base32 Encoder / DecoderEncode and decode Base32 (RFC 4648), Base32hex, Crockford and z-base-32 from text, hex or files.CSV to Excel ConverterConvert CSV files to a real .xlsx workbook with typed numbers and dates, one sheet per file.Hex to Text ConverterConvert hex to text and text to hex with UTF-8 support and space, 0x, \x or comma formats.JSON to CSVConvert JSON data to CSV for spreadsheets.CSV to JSONConvert CSV data to JSON with live preview.Excel to CSVConvert XLSX spreadsheets to CSV.CSV ViewerOpen a CSV or TSV file as a sortable, filterable table.Excel Viewer (XLSX / XLS)Open XLSX, XLS and ODS spreadsheets in your browser without Excel.Markdown to HTMLConvert Markdown to clean HTML with a live editor.XML to JSONConvert XML to JSON with validation.JSON ViewerExplore JSON as a collapsible tree, search keys and values and copy any node's path.TTF to WOFF2 ConverterConvert TTF and OTF fonts to WOFF2 or WOFF and get a ready @font-face CSS snippet.Chmod CalculatorConvert Linux file permissions between checkboxes, octal (755) and symbolic (rwxr-xr-x) notation.JSON to TypeScriptGenerate TypeScript interfaces or types from JSON, with nested types and optional fields.Morse Code TranslatorTranslate text to Morse code and back, then play it as sound or a blinking light, or save a WAV.HTML Table GeneratorBuild HTML tables in an editable grid with styles, header rows, CSV import and live preview.HTML to Markdown ConverterTurn HTML or pasted rich text into clean Markdown with tables and live preview.Markdown Table GeneratorBuild Markdown tables in a grid or paste from Excel/CSV, with alignment and preview.JSON ValidatorCheck JSON with the exact line and column of each error, fix tips and one-click auto-fix.Image to Base64Convert images to Base64 data URIs, CSS backgrounds and HTML img tags in your browser.Base64 to ImagePaste a Base64 string or data URI to preview, identify and download the image.JSON CompareCompare two JSON documents and see every added, removed and changed path.Hex to DecimalConvert hex to decimal instantly with steps and signed mode.Decimal to HexConvert decimal to hex instantly with steps and signed mode.Binary to DecimalConvert binary to decimal instantly with steps and signed mode.Decimal to BinaryConvert decimal to binary instantly with steps and signed mode.Two's Complement CalculatorDecimal to two's complement binary and back for 4-64 bits, with invert-and-add-1 steps.XML to CSV ConverterConvert XML to CSV: detects repeating records, flattens nested data, pick your columns.CSV to XML ConverterConvert CSV to well-formed XML with custom root and row names, escaping and pretty print.TOML to JSON ConverterConvert TOML to JSON and JSON to TOML with a full v1.0 parser and clear error lines.JSON to Go StructTurn JSON into Go structs with inferred types, nested structs and json tags.JSON to Python ClassGenerate Python dataclasses, Pydantic models or TypedDicts with type hints from JSON.JSON to C# ClassConvert JSON to C# classes or records with System.Text.Json or Newtonsoft attributes.ENV to JSON ConverterConvert .env files to JSON or YAML and JSON back to .env, with quotes and multiline values.File to Base64Convert any file to a Base64 string or data URI with MIME detection, line wrap and download.HTML Table to CSVExtract any table from HTML or page source to CSV, TSV or JSON, with colspan and rowspan handled.IEEE 754 Floating Point ConverterConvert decimals to 32/64-bit IEEE 754 floats: toggle bits, see hex, exact value and rounding error.INI to JSON ConverterConvert INI and CFG files to JSON and JSON back to INI, with sections, arrays and types.IP Address ConverterConvert IPv4 to decimal, hex, binary, octal and back, with class and private/public check.ISBN Converter & ValidatorConvert ISBN-10 to ISBN-13 and back, validate check digits and hyphenate, one or in bulk.JSON Flatten / UnflattenFlatten nested JSON to dot or bracket path keys, or unflatten flat keys back to nested JSON.JSON to Dart ClassTurn JSON into Dart model classes with fromJson, toJson, null safety and nested classes.JSON to Java ClassTurn JSON into Java POJOs or records with Lombok, getters/setters and Jackson or Gson annotations.JSON to Kotlin Data ClassTurn JSON into Kotlin data classes for kotlinx.serialization, Gson, Moshi or Jackson.JSON to Markdown TableTurn a JSON array of objects into a GitHub Markdown table with column picker and alignment.JSON to PHP ArrayConvert JSON to PHP array code (short [] or array()) and PHP arrays back to JSON.JSON to Rust StructTurn JSON into Rust structs with serde derives, rename attributes, Option and Vec types.JSON to SQL ConverterConvert a JSON array of objects to CREATE TABLE and INSERT statements for MySQL, Postgres, SQLite.JSON to Swift StructTurn JSON into Swift Codable structs with CodingKeys, optionals and nested types.JSON to TOML ConverterConvert JSON to clean TOML with tables, arrays of tables, inline tables and dates.JSONL to JSON ConverterConvert JSON Lines / NDJSON to a JSON array and back, with line-level error reports.Properties to YAML ConverterConvert Java .properties to nested YAML (application.yml) and YAML back to properties.PX to EM ConverterConvert pixels to em using the parent font size, and em back to px, with conversion tables.Query String to JSONConvert URL query strings to JSON with nested brackets and arrays, and JSON back to a query string.REM to PX ConverterConvert CSS rem values to pixels for any root font size, with a quick 0.25–6rem table.SQL to JSON ConverterConvert SQL INSERT statements and dumps into a JSON array of row objects, with CSV export.TSV to CSV ConverterConvert TSV to CSV and back, or between tab, comma, semicolon and pipe, with correct quoting.TypeScript to JavaScriptConvert TypeScript or TSX to clean JavaScript instantly: strip types, keep or compile JSX.XML to YAML ConverterConvert XML to clean YAML with attributes, text nodes, lists and exact error lines.YAML to XML ConverterConvert YAML to pretty, well-formed XML with custom root, attributes and array item tags.Boolean Algebra SimplifierSimplify boolean expressions or minterm lists to minimal SOP and POS with Quine-McCluskey steps.Compare Excel FilesCompare two Excel spreadsheets cell by cell, highlight changes and export a diff report.CSV CleanerClean messy CSV in one click: trim spaces, drop empty rows and columns, fix headers, dedupe.
See all 129 Data & File Format Converters →