Text to Hex
Text to hex bytes — UTF-8 encoded, two digits each, in the form you would paste into a dump, an escape sequence or a literal.
Runs 100% in your browser•Nothing is uploaded to a server•Free forever
Text
Hexadecimal
Two hex digits per byte, always
Text becomes hex in two steps: encode the characters to bytes with UTF-8, then write each byte as exactly two hex digits. The "exactly two" is what makes the output parseable — 0A and A are the same number, but only the padded form can be read back unambiguously from a stream where the bytes are not separated.
Hex is the notation of choice here rather than binary because it is four times shorter and still maps cleanly onto byte boundaries. A sentence in binary is a wall; the same sentence in hex is something you can scan.
What a hex dump looks like
Tools like xxd, hexdump and every binary editor lay bytes out in fixed-width rows with an offset on the left and a printable rendering on the right. Non-printable bytes show as a dot, which is why the dump below has one at the end — the trailing newline:
| Offset | Bytes | As text |
|---|---|---|
00000000 | 48 65 78 20 69 73 20 6A | Hex is j |
00000008 | 75 73 74 20 62 79 74 65 | ust byte |
00000010 | 73 2E 0A | s.. |
The offset column is a byte count from the start of the data, in hex. That is the number a debugger, a parser error or a diff will quote at you, so being able to line it up against the row is most of what reading a dump is.
Where the hex is going
The same bytes get written several different ways depending on what will read them, and picking the wrong form is a common source of "the value looks right but does not work":
| Where you would write it | Form |
|---|---|
| C, Python, JavaScript string | \x48\x69 |
| a numeric literal | 0x4869 |
| percent-encoding in a URL | %48%69 |
| an HTML numeric entity | Hi |
| a Unicode code point | U+0048 U+0069 |
Percent-encoding in particular is not the same job as hex: it only escapes the bytes a URL cannot carry literally, leaving the rest as characters. If that is what you need, use the URL encoder instead of pasting a full hex string into a query parameter.
Non-ASCII costs more than one byte
Every character above U+007F takes two to four bytes in UTF-8, so its hex is four, six or eight digits rather than two. That is why a string's character count and its hex length are not related by a constant, and why truncating a hex string at an arbitrary even offset can cut a character in half.
Related: hex to text for reading a dump back, text to binary when you want the individual bits, and the hash generator if what you actually want is a digest of the bytes.
More developer tools
- JSON Formatter
- Base64 Encode / Decode
- URL Encoder / Decoder
- Unix Timestamp Converter
- Regex Tester
- UUID Generator (v4 / v7)
- Hash Generator (MD5 / SHA / HMAC)
- JWT Decoder
- Password Generator
- JSON ⇄ CSV Converter
- HTML Entity Encoder / Decoder
- Cron Expression Explainer
- Color Converter
- WCAG Contrast Checker
- All tools on one page (home)