Text to Hex Converter
Convert plain text to hexadecimal representation for encoding and debugging.
What Is Hexadecimal Encoding?
Hexadecimal (hex) is a base-16 numbering system using digits 0–9 and letters A–F. In computing, hex is commonly used to represent binary data in a compact, human-readable form. Each byte (8 bits) is represented as exactly two hex digits — for example, the ASCII letter H is 48, and a space is 20. Hex encoding is widely used in debugging, network protocols, cryptography, and file format analysis.
How Text → Hex Conversion Works
- Each character in the input is encoded to bytes using UTF-8 via the browser's
TextEncoderAPI. - ASCII characters (A–Z, a–z, 0–9, common punctuation) produce exactly one byte each.
- Non-ASCII characters (accented letters, CJK, emoji) produce 2–4 bytes each — the hex output will be longer than the character count.
- Each byte is converted to a two-digit hex number (e.g. byte
72→48). - The separator, case, and 0x prefix options control how the hex bytes are joined.
How Hex → Text Conversion Works
- Input is normalised:
0xprefixes, colons, commas, and spaces are stripped. - The remaining string is split into 2-character hex pairs.
- Each pair is parsed as an integer (base 16) to produce a byte value.
- The byte sequence is decoded as a UTF-8 string via
TextDecoder, recovering the original text.
Separator Formats and 0x Prefix
- SP (space) —
48 65 6c 6c 6f— Most readable. Standard in network dumps and xxd output. - : (colon) —
48:65:6c:6c:6f— Common in MAC addresses, TLS certificate fingerprints, and OpenSSL output. - ∅ (none) —
48656c6c6f— Compact. Used for embedding hex strings in source code or JSON. - 0x prefix —
0x48 0x65 0x6c— Standard notation in C, C++, and assembly. Works with any separator. - Uppercase / Lowercase —
4865vs4865— Both are valid hex; use uppercase for display, lowercase for most code contexts.
What Is UTF-8 and Why Does It Matter Here?
UTF-8 is a variable-width character encoding that represents every Unicode code point. ASCII characters use 1 byte, Latin/European accented characters use 2 bytes, CJK characters use 3 bytes, and emoji use 4 bytes. This tool uses UTF-8 for both directions — so the byte count shown may exceed the character count when non-ASCII text is encoded. For example, the emoji 🌍 encodes to 4 bytes: f0 9f 8c 8d.
Common Use Cases
- Network debugging — Inspecting raw packet payloads in Wireshark or tcpdump hex dumps.
- File signatures (magic bytes) — PDF files start with
25 50 44 46(i.e.,%PDF); PNG files start with89 50 4e 47. - Cryptographic output — Hash digests and encryption keys are typically expressed as hex strings.
- Source code — Embedding binary constants in C (
0x48, 0x65) or Python (\x48\x65). - TLS / SSL certificates — Certificate fingerprints and serial numbers use colon-separated hex.
- Data encoding — When binary data must be transported as a text-safe string without Base64.
Hex Quick Reference Table
| Char | Hex | Char | Hex | Char | Hex |
|---|---|---|---|---|---|
| Space | 20 | A | 41 | a | 61 |
| 0 | 30 | B | 42 | b | 62 |
| 1 | 31 | C | 43 | c | 63 |
| 9 | 39 | Z | 5a | z | 7a |
| \n (LF) | 0a | \r (CR) | 0d | \t (Tab) | 09 |
Related Tools
- Base64 Encoder / Decoder — encode binary data as ASCII-safe Base64 strings.
- URL Encoder / Decoder — percent-encode special characters for use in URLs.
- Hash Generator — generate MD5, SHA-256, SHA-512 hashes (output is hex).
- Number Base Converter — convert between binary, octal, decimal, and hex numbers.