Hex Encoder

Accurate hexadecimal encoder/decoder: convert any text (ASCII, Unicode, Emoji) to hexadecimal representation and back. Follows the Base16 encoding scheme defined in RFC 4648 and the WHATWG Encoding Standard.

Original Text (UTF-8)
0 characters
Hexadecimal (Base16)
0 bytes
Formatting options affect hex display only. Decoding automatically handles spaces, colons, '0x' prefixes, and mixed case.
Examples: Hello World Multilingual: 日本語 ? Emoji party ??✨ JSON snippet Decode hex: 48657820656e636f64696e67
Hex length: 0 characters
Encoding: UTF-8 (WHATWG Encoding Standard)
Privacy: Local only. No data is sent to any server – all conversions happen inside your browser.

What is Hexadecimal Encoding (Base16)?

Hexadecimal (hex) is a base‑16 numeral system using digits 0‑9 and letters A‑F. Each hex digit represents exactly 4 bits. When encoding text, the string is first transcoded to a sequence of UTF‑8 bytes; each byte is then represented by two hexadecimal digits. This encoding is formally defined as Base16 in RFC 4648 and is widely used in computing: memory dumps, color values, cryptographic hashes, and low‑level data inspection.

⚙️ How it works (algorithmic description):

1. Input text → UTF‑8 encoded byte sequence using TextEncoder (standard Web API, compliant with WHATWG).
2. Each byte (0–255) is converted to a two‑character hex representation (e.g., 65 → "41").
3. Optional formatting: spaces, colons, or no delimiter between bytes.
4. Decoding reverses: sanitize hex string (strip spaces, colons, optional "0x" prefixes), group into bytes, then decode via TextDecoder (UTF‑8).

Test Vectors – Verify Accuracy Yourself

You can manually test the tool against these known input/output pairs to confirm correctness. All examples follow RFC 4648 and UTF‑8 encoding.

Input Text UTF‑8 Hex (lowercase, no delimiter) Expected output
"A" 41 Decodes back to "A"
"Hello" 48656c6c6f Decodes back to "Hello"
"€" (Euro sign) e282ac Decodes to "€" (U+20AC, UTF-8: 0xE2 0x82 0xAC)
"?" (rocket) f09f9a80 Decodes to "?" (U+1F680, 4-byte UTF-8)
"こんにちは" e38193e38293e381abe381a1e381af Decodes to original Japanese
You can also cross‑verify with independent tools like CyberChef (Recipe: "To Hex" / "From Hex") using the same UTF‑8 encoding.

Known Limitations & Scope

  • Performance: Designed for text up to ~1 MB. Larger inputs may cause browser slowdown or UI lag.
  • Encoding only UTF-8: Does not support UTF‑16LE, UTF‑16BE, or legacy encodings (e.g., ISO‑8859‑1). For binary file hexdumps, please use a dedicated hex editor.
  • Invalid hex handling: If hex input contains non‑hex characters or odd length, the tool will show an error. No data is silently corrupted.
  • Decoding failures: If hex decodes to byte sequences that are not valid UTF‑8, replacement characters (�) may appear – this follows the WHATWG “fatal = false” behaviour.
These limitations are intentional and transparent, ensuring the tool is used within its intended scope.

Real‑world Applications & Standards

  • Cybersecurity: Malware analysts inspect hexdumps for file signatures (e.g., PDF magic bytes "25504446").
  • Web Development: CSS colours (#RRGGBB), percent‑encoding fallback, and WebSocket binary frame inspection.
  • Cryptography: Hash outputs (SHA‑256, MD5) are almost universally displayed as hexadecimal strings.
  • Network Engineering: MAC addresses, IPv6 addresses, and protocol debugging (e.g., TLS handshake dumps).
  • Standards Compliance: Our implementation adheres to WHATWG Encoding Standard and RFC 4648 (Base16).

Technical Deep Dive: UTF‑8 & Hex Accuracy

Unlike naive ASCII‑only converters, this tool fully supports the entire Unicode repertoire (including emojis, CJK ideographs, and mathematical symbols). It uses the browser’s native TextEncoder and TextDecoder, which are maintained by browser vendors to comply with the latest Unicode standard (v15.1 as of 2025). The hex conversion itself is a simple mapping: each byte is transformed using byte.toString(16).padStart(2,'0'), and decoding uses parseInt(byteHex, 16). This is deterministic and can be verified against any reference implementation.

The decoder is intentionally robust: it strips spaces, colons, newlines, and even optional "0x" prefixes before converting. This makes it compatible with hex dumps from various sources (Wireshark, xxd, etc.). However, it does not attempt to guess missing leading zeros – if the hex string has an odd number of characters, an error is raised.

Frequently Asked Questions

No. Base64 uses 64 characters and is more space‑efficient (3 bytes → 4 characters). Hex uses 16 characters and doubles the size (1 byte → 2 hex digits). Hex is simpler and easier to read for small byte lengths.

No – it explicitly uses UTF‑8, the dominant encoding for the web. If you need UTF‑16 hex dumps, consider using a programming language or a dedicated hex editor. We may add optional encoding selection in the future.

This happens when the hex string decodes to a byte sequence that is not valid UTF‑8. The WHATWG decoder replaces invalid sequences with the Unicode replacement character U+FFFD rather than throwing an error. This is intentional and reversible only if you re‑encode from the original text.

For small text files you can copy‑paste the content. For binary files (images, executables) or large files, please use a dedicated hex editor (e.g., HxD, xxd, or ImHex). This tool is designed for textual data only.

You can use the test vectors provided above and compare with independent tools such as CyberChef (using the "To Hex" and "From Hex" operations with UTF‑8). All conversions are deterministic and open to inspection via browser developer tools.
Standards & self‑verification: Implementation follows RFC 4648 (Base16) and WHATWG Encoding Standard (UTF‑8). Last self‑checked against Unicode 15.1 and RFC test vectors: May 2026. No third‑party guarantees are implied – users are encouraged to verify using the test vectors above.

Public references: RFC 4648 (Base16), WHATWG Encoding Standard, MDN Web Docs: Base16. This tool is provided as‑is with a focus on transparency and accuracy.

Related encoding & developer tools