How do you convert text to hexadecimal?
Encode the text as bytes (UTF-8), then write each byte as two hex digits. "Hello" is the bytes 72, 101, 108, 108, 111, which in hex are 48 65 6C 6C 6F. Each hex digit stands for 4 bits, so one byte is always exactly two digits (00–FF).
Hex table for letters and digits
| Char | Hex | Char | Hex | Char | Hex |
|---|---|---|---|---|---|
| A | 41 | a | 61 | 0 | 30 |
| B | 42 | b | 62 | 1 | 31 |
| C | 43 | c | 63 | 2 | 32 |
| D | 44 | d | 64 | 3 | 33 |
| E | 45 | e | 65 | 4 | 34 |
| F | 46 | f | 66 | 5 | 35 |
| G | 47 | g | 67 | 6 | 36 |
| H | 48 | h | 68 | 7 | 37 |
| I | 49 | i | 69 | 8 | 38 |
| J | 4A | j | 6A | 9 | 39 |
| K | 4B | k | 6B | Space | 20 |
| L | 4C | l | 6C | . | 2E |
| M | 4D | m | 6D | , | 2C |
| N | 4E | n | 6E | ! | 21 |
| O | 4F | o | 6F | ? | 3F |
| P | 50 | p | 70 | ||
| Q | 51 | q | 71 | ||
| R | 52 | r | 72 | ||
| S | 53 | s | 73 | ||
| T | 54 | t | 74 | ||
| U | 55 | u | 75 | ||
| V | 56 | v | 76 | ||
| W | 57 | w | 77 | ||
| X | 58 | x | 78 | ||
| Y | 59 | y | 79 | ||
| Z | 5A | z | 7A |
Text to hex in Python, JavaScript and Excel
| Where | Text → hex | Hex → text |
|---|---|---|
| Python | "Hello".encode().hex() | bytes.fromhex("48656c6c6f").decode() |
| JavaScript | [...new TextEncoder().encode(s)].map(b=>b.toString(16).padStart(2,"0")).join("") | new TextDecoder().decode(Uint8Array.from(h.match(/../g),x=>parseInt(x,16))) |
| Excel | =DEC2HEX(UNICODE(A1)) per character | =UNICHAR(HEX2DEC("48")) |
Excel's UNICODE returns the code point, which equals the UTF-8 byte only for ASCII characters.
Hex to text: which formats are accepted?
Pairs with spaces (48 65), one continuous string (4865), C-style 0x48 0x65, and escaped \x48\x65. Commas and colons are ignored.
Why do some characters become 2–4 hex bytes?
UTF-8 stores characters beyond ASCII in several bytes: "é" is C3 A9, "한" is ED 95 9C, and "😀" is F0 9F 98 80.
Sources: RFC 3629 (UTF-8) · Microsoft Support, UNICODE function. Checked October 2026.