Skip to content
AgileLogics

ASCII to Hex

Converts your text into its UTF-8 bytes as 2-digit hexadecimal values, space-separated.

How it works

Type or paste text into the input panel and click Convert.

How do you convert ASCII to hex?

Take each character's ASCII code and write it in base 16. H is 72 in decimal, which is 48 in hex, because 4 × 16 + 8 = 72. This converter does that for every character in your text and prints the bytes as lowercase two-digit pairs separated by spaces, so Hi! becomes 48 69 21.

Hex is the usual way to show raw bytes because two hex digits cover exactly one byte (00 to ff), and the ASCII range fits inside 00 to 7f.

Using the converter

  1. Type or paste the text.
  2. Click Convert.
  3. Copy the hex. Every byte is two digits, so a tab comes out as 09, not 9.

Example: GET / converts to 47 45 54 20 2f. If you've ever looked at an HTTP request in a packet capture, those are the first bytes you'll see on the wire, and recognising 47 45 54 20 as "GET " is a handy debugging reflex.

Reading ASCII hex without a chart

The ASCII layout is cleaner in hex than in decimal, because character groups start on round numbers:

Hex range Characters Pattern
00 to 1f Control codes 09 tab, 0a line feed, 0d carriage return
20 Space
30 to 39 Digits 0 to 9 Second digit equals the digit: 37 is 7
41 to 5a A to Z 41 is A
61 to 7a a to z Lowercase = uppercase + 20
7f DEL Last ASCII code

Two tricks fall out of this. A digit character is 3 followed by the digit itself, so 2026 is 32 30 32 36. And uppercase and lowercase letters differ only in the 20 bit: 41 is A, 61 is a. Converting AZaz gives 41 5a 61 7a, which shows both ends of each alphabet. The ASCII table has the complete list if you need a symbol.

Turning the output into code

Space-separated pairs are easy to read, but code usually wants a specific notation. These are the common ones for the bytes of Hi:

Where Notation How to get it from the output
C, Python, JavaScript strings "\x48\x69" Replace each space with \x and add \x at the start
C or Java byte array {0x48, 0x69} Replace each space with , 0x and add 0x at the start
Python bytes.fromhex() bytes.fromhex('48 69') Paste as-is, spaces are allowed
URL percent-encoding %48%69 Replace each space with % and add % at the start
HTML numeric reference Hi Wrap each byte in &#x and ;

The find and replace tool handles these rewrites in one step. Python's bytes.fromhex accepts whitespace between pairs, so this page's output works there without changes. For URLs, note that you'd normally percent-encode only reserved characters, not letters; RFC 3986 lists which ones, and the URL encoder applies those rules for you. The HTML form works byte for byte only with ASCII; for other characters HTML references the code point (é is é), not the UTF-8 bytes.

Past the ASCII range

Strict ASCII stops at 7f. When your text contains anything beyond that, the converter switches to UTF-8 bytes rather than failing, following RFC 3629. é becomes c3 a9 and € becomes e2 82 ac. Two consequences:

  • The byte count no longer equals the character count. café is four characters but five bytes.
  • Any byte from 80 to ff in the output tells you the input had a non-ASCII character in it.

If multi-byte encoding is the thing you're actually investigating, the text to hex guide covers it in depth. For pure ASCII input, every character gives exactly one pair, so you can line the output up against the input one-to-one.

Checking your result

Paste the hex into hex to ASCII and you should get your original text back exactly. If you edited the pairs by hand, that round trip is the quickest way to catch a typo, since a single wrong digit changes a character and a missing digit makes the pair count odd, which the decoder rejects.

Last updated

Frequently asked questions

What is the hex value of an ASCII character?
It's the character's ASCII code written in base 16, always two digits. A is 41, a is 61, a space is 20, the digit 0 is 30 and a line feed is 0a. The ASCII range runs from 00 to 7f.
Is the output uppercase or lowercase hex?
Lowercase, with every byte padded to two digits and separated by a single space, for example 48 69 21. Hex is case-insensitive, so 2F and 2f mean the same byte.
How do I get 0x48 or \x48 format instead of spaces?
Use find and replace on the output. Replace each space with a space plus 0x (and add 0x before the first byte), or replace spaces with \x for an escaped string. The table in this guide shows the common notations.
What happens with characters that aren't ASCII?
They're encoded as UTF-8, so they take two to four bytes. é becomes c3 a9 and € becomes e2 82 ac. Plain ASCII characters are always exactly one byte.
Can I convert hex back to ASCII?
Yes, with the Hex to ASCII converter. It accepts the space-separated output from this page or the same pairs with no spaces.