Text to Hex
Convert text into hexadecimal bytes (UTF-8), with your choice of separator, prefix and letter case.
Paste or drop
Paste text below, or drop a file instead.
Choose an output
Convert text into hexadecimal bytes (UTF-8), with your choice of separator, prefix and letter case.
Fine-tune
Optional — sensible defaults are already set.
About Text to Hex
Convert text into hexadecimal bytes, using two hex digits per UTF-8 byte, so 'Hi' becomes 48 69. You choose the separator, an optional 0x or \x prefix, and uppercase or lowercase letters to match the format your code, documentation or tool expects.
When it helps
- Writing string literals as escaped bytes for C, Python or shell scripts using the \x prefix.
- Building byte arrays for code with the 0x prefix and comma separator.
- Comparing a string's bytes with what a hex editor or packet capture shows.
- Spotting hidden characters, such as a non-breaking space (c2 a0), that look the same as normal ones.
Tips
- Pick '\x' with no separator to get a string like \x48\x69 you can paste straight into most programming languages.
- Pick '0x' with a comma separator for array syntax, then wrap the result in braces or brackets.
- Colon-separated output matches the style used for MAC addresses and many certificate fingerprints.
- Each byte is shown separately, so a non-ASCII character shows as several hex pairs rather than one Unicode code point.
Good to know
Quick answers about text to hex in your browser.
Only for ASCII characters. 'é' is code point U+00E9 but is stored in UTF-8 as the two bytes c3 a9, and this tool shows the bytes. Most programs and file formats work with the bytes.
Hexadecimal is base 16, using digits 0-9 and letters a-f. One hex digit represents exactly 4 bits, so every byte fits in exactly two digits, which is shorter and easier to read than eight binary digits.
Yes. There is no sign-up, no watermark and no limit on how many files you process.
No. Files are read and processed locally in your browser, so they never leave your device.
Related tools
Part of the Text Tools collection.