Text Encoder Decoder
Convert text between UTF-8, UTF-16, and Latin1 encodings into hex, percent, decimal, or binary formats. Free, fast, and 100% client-side — no data ever leaves your browser.
- Home
- Encoder & Decoder
- Text Encoder & Decoder
What is Text Encoding?
Text encoding defines how characters are represented as bytes in computer systems. Different encodings use different byte sequences to represent the same text. Understanding encodings is essential for working with international text, APIs, databases, and file formats.
This tool supports three major encodings:
- UTF-8 — The dominant encoding on the web. Uses 1-4 bytes per character, backward-compatible with ASCII. Recommended for almost all modern applications.
- UTF-16 — Uses 2 or 4 bytes per character. Used internally by JavaScript, Java, and Windows APIs. Our tool uses little-endian byte order.
- Latin1 (ISO-8859-1) — A single-byte encoding covering Western European languages. Can only represent 256 characters.
UTF-8 vs UTF-16 vs Latin1 — Quick Comparison
| Property | UTF-8 | UTF-16 | Latin1 (ISO-8859-1) |
|---|---|---|---|
| Bytes per character | 1 – 4 | 2 or 4 | 1 (always) |
| Character range | All Unicode (1.1M+) | All Unicode (1.1M+) | 256 characters only |
| ASCII compatibility | Yes (1 byte) | No (2 bytes + BOM) | Yes (1 byte) |
| BOM required | No (optional) | Optional (common) | No |
| Web usage (W3C) | Recommended | Legacy / internal | Legacy only |
| Typical use | HTML, JSON, APIs, files | Java, JS internals, .NET | Western European legacy |
When Should You Use Text Encoding?
API & Webhook Debugging
Inspect raw byte values when an API returns garbled text or unexpected characters. Hex view reveals the exact encoding used.
Internationalization (i18n)
Convert translated strings between encodings when migrating legacy databases or merging files from different systems.
Mojibake Diagnosis
Figure out why text appears as "é" or "’" — these are classic encoding mismatches this tool helps you identify and fix.
Database Migration
Encode CSV or SQL dump contents as hex to safely transfer between systems with different default encodings.
Security Analysis
Examine URL-encoded or hex-encoded payloads to detect obfuscated injection attempts or hidden characters in logs.
File Format Inspection
Check the encoding of files or binary blobs to identify BOM markers, null bytes, or encoding signatures.
Common Encoding Pitfalls
Mojibake from double-encoding
If text is encoded twice (e.g., UTF-8 bytes encoded as Latin1), you'll see garbled characters like "é". Decode once with the original encoding, then re-encode correctly.
BOM bytes in UTF-16
UTF-16 files often start with a Byte Order Mark (0xFF 0xFE for little-endian). This is normal but can cause issues when the BOM is treated as visible text.
Latin1 can't hold non-Western characters
Trying to encode Chinese, Arabic, or emoji into Latin1 will fail silently or produce ? replacement characters. Use UTF-8 for any non-ASCII text.
Percent-encoding vs URL encoding
Percent encoding in this tool encodes every byte. URL encoding typically leaves unreserved characters (A-Z, a-z, 0-9, - _ . ~) unchanged. For full URL encoding, use our dedicated URL Encoder/Decoder.
Text Encoding in Code
JavaScript (Browser)
const encoder = new TextEncoder();
const bytes = encoder.encode("Hello");
// Uint8Array [72, 101, 108, 108, 111]
const hex = [...bytes].map(b => b.toString(16).padStart(2, '0')).join(' ');
// "48 65 6c 6c 6f"
Python
# UTF-8 to hex
text = "Hello"
hex_str = text.encode("utf-8").hex(" ")
# "48 65 6c 6c 6f"
# Hex back to text
bytes_obj = bytes.fromhex(hex_str)
result = bytes_obj.decode("utf-8")
Node.js
const buf = Buffer.from("Hello", "utf-8");
console.log(buf.toString("hex"));
// "48656c6c6f"
How to Use
- Choose mode — Toggle between Encode Text and Decode Text mode at the top.
- Select encoding — Choose the target encoding (UTF-8, UTF-16, or Latin1) and output format (Hex, Percent, Decimal, or Binary).
- Enter your text — Type or paste the text or encoded bytes into the input area.
- Convert — Click Encode or Decode to process. Use Swap to exchange input and output. Click Load Example for sample data.
- Copy or download — Use the copy button on the output area or click Download .txt to save the result.
Frequently Asked Questions
What is the difference between encoding and encryption?
Encoding transforms data into a different format for interoperability (like UTF-8 bytes or hex), while encryption secures data so it cannot be read without a key. Encoding is reversible without a key and is not designed for security.
Why do I see different byte sequences for the same text?
Different encodings represent the same characters using different byte sequences. For example, the character "é" is one byte (0xE9) in Latin1 but two bytes (0xC3 0xA9) in UTF-8. This tool lets you compare how the same text looks in different encodings.
What output formats are available?
You can view encoded bytes in four formats: Hex (48 65 6C), Percent (%48%65%6C, URL-style), Decimal (72 101 108), and Binary (01001000 01100101 01101100). All formats are space-separated for readability.
Is this tool safe for sensitive data?
Yes. All processing happens entirely in your browser using JavaScript's built-in TextEncoder and TextDecoder APIs. Your data is never uploaded to any server, stored, or logged.
How do I fix garbled text (mojibake) from a copied file?
Mojibake happens when bytes encoded in UTF-8 are misinterpreted as Latin1 (or vice versa). Paste the garbled text here, try decoding with each encoding, and pick the one that produces readable output. The most common fix is re-encoding: decode as Latin1, then re-encode as UTF-8.
Related Encoder & Decoder Tools
Base64 Encoder/Decoder
Encode and decode Base64 strings
URL Encoder/Decoder
Encode and decode URL strings
HTML Entities Converter
Encode/decode HTML entities
Punycode Converter
Convert domain names to/from Punycode
Text Encoder/Decoder
Encode/decode text in various formats