Text to hex
dev247
646576323437
d is 0x64, e is 0x65, v is 0x76, and the digits 2, 4, 7 are 0x32, 0x34 and 0x37.
Convert text or files to hexadecimal bytes and hex back to text. Choose plain, spaced, colon or 0x formats, and decode hex dumps with any separator.
0x prefixes or \x escapes, and lowercase or uppercase.0x and \x are ignored automatically. Copy or download the result.dev247
646576323437
d is 0x64, e is 0x65, v is 0x76, and the digits 2, 4, 7 are 0x32, 0x34 and 0x37.
48 65 6c 6c 6f
Hello
Spaces, colons and 0x prefixes are all accepted when decoding.
é
c3a9
Characters outside ASCII take more than one byte in UTF-8. é is two bytes: 0xC3 and 0xA9.
0x48 0x69 0x21
Hi!
Byte lists like this often come from C arrays, debuggers and protocol docs.
Hex encoding, also called Base16, writes every byte as two hexadecimal digits from 0–9 and a–f. One hex digit stands for 4 bits (a "nibble"), so two digits describe one byte exactly: 00 is 0 and ff is 255. Text to hex means: convert the text to bytes (UTF-8 on this page), then write each byte in hex.
Hex doubles the size of the data, which makes it bigger than Base64. In return, it is easy to read: you can see every byte, line up values, and spot patterns at a glance. That is why debuggers, hash functions and network tools show data in hex.
| Hex | Bits | Decimal | Hex | Bits | Decimal |
|---|---|---|---|---|---|
| 0 | 0000 | 0 | 8 | 1000 | 8 |
| 1 | 0001 | 1 | 9 | 1001 | 9 |
| 2 | 0010 | 2 | a | 1010 | 10 |
| 3 | 0011 | 3 | b | 1011 | 11 |
| 4 | 0100 | 4 | c | 1100 | 12 |
| 5 | 0101 | 5 | d | 1101 | 13 |
| 6 | 0110 | 6 | e | 1110 | 14 |
| 7 | 0111 | 7 | f | 1111 | 15 |
For example, the letter H is byte 72. In bits that is 0100 1000, and the two nibbles 0100 and 1000 are 4 and 8, so H is 48 in hex.
The bytes are always the same, but different tools write them differently:
| Format | Example for Hi! | Where you see it |
|---|---|---|
| Plain | 486921 | Hashes, keys, API values |
| Spaced | 48 69 21 | Hex dumps, packet captures |
| Colon-separated | 48:69:21 | MAC addresses, certificate fingerprints |
0x prefix | 0x48 0x69 0x21 | C/C++ arrays, debuggers |
\x escapes | \x48\x69\x21 | String literals in Python, PHP, JavaScript, shell |
| Percent-encoding | %48%69%21 | URLs (only for unsafe characters) |
Hex digits are not case-sensitive: c3a9 and C3A9 are the same bytes. Lowercase is the convention for hashes; uppercase is common in hardware and network documentation.
Hex shows bytes, not characters, so the result depends on how the text is turned into bytes. This tool uses UTF-8, the encoding used by the web, JSON and most APIs:
A–Z, digits, punctuation) are 1 byte each: A → 41.é → c3 a9.☕ → e2 98 95.😀 → f0 9f 98 80.If another tool shows e9 for é, it is using Latin-1 (ISO-8859-1) instead of UTF-8.
#ef4444 is three bytes of red, green and blue.\x00 for bytes that cannot be typed.// Browser: text → hexconst hex = Array.from(new TextEncoder().encode('Hi!'), (b) => b.toString(16).padStart(2, '0')).join(''); // "486921" // Browser: hex → textconst bytes = Uint8Array.from(hex.match(/../g), (h) => parseInt(h, 16));const text = new TextDecoder().decode(bytes); // Node.jsBuffer.from('Hi!').toString('hex'); // "486921"Buffer.from('486921', 'hex').toString('utf8'); // "Hi!"$hex = bin2hex('Hi!'); // "486921"$text = hex2bin($hex); // "Hi!"hex_str = 'Hi!'.encode('utf-8').hex() # "486921"spaced = 'Hi!'.encode().hex(' ') # "48 69 21"text = bytes.fromhex('48 69 21').decode() # "Hi!"echo -n 'Hi!' | xxd -p # 486921echo '486921' | xxd -r -p # Hi!xxd file.bin | head # hex dump with offsets and ASCIIhexdump -C file.bin | head # the same, another classic formathex2bin(): Hexadecimal input string must have an even length (PHP) or "odd number of hex digits"
Every byte needs two digits, so one digit is missing or extra. A common cause is a dropped leading zero, such as 7 instead of 07.
ValueError: non-hexadecimal number found in fromhex() arg (Python)
The input contains characters other than 0–9, a–f and spaces, such as 0x prefixes or colons. Remove them first, or paste the value here: this tool ignores common separators and points to the first invalid character.
The decoded text shows strange characters like é
The bytes are UTF-8 but were read as Latin-1, or the other way round. Decode as UTF-8. If the original was written in another encoding, convert it to UTF-8 first.
Converting a number gives a different result than expected
This tool converts bytes, not numbers. The text 255 becomes 323535 (three characters), while the number 255 is ff. Use a number base converter for numeric values.
The decoded result says "Binary data"
The bytes are not valid text: they are probably a file, a hash or encrypted data. Use Download to save the bytes. Images also show a preview.
Choose Encode and type your text. Each character is converted to its UTF-8 bytes, and each byte is written as two hex digits. Hi! becomes 486921.
Yes. RFC 4648 calls it Base16: 16 symbols (0–9 and A–F), each representing 4 bits, so two symbols represent one byte.
Each byte (8 bits) needs two hex digits (4 bits each). Hex adds 100% to the size, compared with 33% for Base64.
No. ff, FF and Ff are the same value. Choose lowercase or uppercase with the Case option.
Yes. Spaces, line breaks, colons, commas, hyphens, 0x prefixes and \x escapes are ignored when decoding.
No. The conversion runs entirely in your browser and nothing is sent to a server.
Free, private developer tools that run in your browser. No signup, nothing uploaded, no waiting.
Tip: press Ctrl D to bookmark dev247.