What is ASCII Text to Hex Converter?
This text to hex converter turns letters, words and whole strings into their hexadecimal character codes. Each ASCII character is one byte, written as two hex digits: H is 48, e is 65, l is 6C and o is 6F, so "Hello" becomes 48 65 6C 6C 6F.
Hex is the standard way to show bytes in debuggers, packet captures, file formats and escape sequences, so converting text to hex helps you build test data, write escaped strings and compare against dumps. Choose uppercase or lowercase, add a 0x prefix and pick the separator.
How to use ASCII Text to Hex Converter
- Type or paste your text.
- Read the hex code for each character.
- Set the options: uppercase or lowercase, 0x prefix, and separator.
- Copy the result, or click Swap to convert hex back to text.
Key features
- Converts text to hex codes, two digits per ASCII character
- Uppercase or lowercase hex
- Optional 0x prefix
- Separator choice: space, comma, new line or none
- Swap button to decode hex back to text
- Runs entirely in your browser
Common use cases
- Creating hex test data for parsers and protocols
- Writing escaped strings such as \x48\x65 in code
- Comparing text with bytes in hex dumps and packet captures
- Building byte arrays for C and embedded code
- Teaching character encoding
Technical details & standards
Each character's code is written in base 16 and padded to two digits: space = 20, 0 = 30, A = 41, a = 61, ~ = 7E. With no separator the result is a continuous hex string, as used by many hashing and binary APIs; with the 0x prefix each byte is written 0x48, as in C arrays.
Codes come from the characters' UTF-16 code units, which match ASCII for all ASCII characters. Characters outside ASCII produce longer values (é is E9 and € is 20AC), which differ from their UTF-8 bytes (C3 A9 and E2 82 AC), so keep text to ASCII when you need byte-exact output.
How to convert text to hex by hand
Each character's code fits in two hex digits, so text to hex is a lookup followed by a division by 16. Here is "Hi!":
- Look up each character's code: H = 72, i = 105, ! = 33.
- Divide each code by 16. The quotient is the first hex digit and the remainder the second: 72 = 4 × 16 + 8, 105 = 6 × 16 + 9, 33 = 2 × 16 + 1.
- Write the digit pairs side by side: 48, 69 and 21.
Result: "Hi!" in hex is 48 69 21. Uppercase letters are always 41–5A and lowercase letters 61–7A, so plaintext in hex is easy to spot in a dump.
String to hex in Python and JavaScript
In code, string to hex means encoding the text as bytes and printing each byte as two hex digits. These use UTF-8, so plain ASCII gives the same result as the converter, while é becomes the two bytes c3 a9.
Python
"Hello".encode().hex() # '48656c6c6f'
"Hello".encode().hex(" ") # '48 65 6c 6c 6f', Python 3.8+
"café".encode().hex(" ") # '63 61 66 c3 a9'JavaScript
Buffer.from("Hello").toString("hex"); // "48656c6c6f" (Node.js)
[...new TextEncoder().encode("café")]
.map(b => b.toString(16).padStart(2, "0")).join(" "); // "63 61 66 c3 a9" (browser)Frequently asked questions
How do I convert text to hex?
Take each character's ASCII code and write it in base 16. "Hi" is 72 and 105, which are 48 and 69 in hex.
What is "Hello" in hex?
48 65 6C 6C 6F, or 48656C6C6F without spaces.
How do I convert a string to hex in code?
Node.js: Buffer.from("Hello").toString("hex"). Python: "Hello".encode().hex(). Both use UTF-8 bytes, which matches this tool for ASCII text.
What is the hex code for a space?
20 (decimal 32). A line feed is 0A, a carriage return 0D and a tab 09.
How are non-English characters shown in hex?
This converter writes one code per character, so é becomes E9. Saved as UTF-8 text, é takes two bytes, C3 A9, which is what a hex editor shows.