Ascii To Hex Converter
Enter the ascii text value to convert to hexadecimal or Hexadecimal to ASCII Text.
ASCII Text:
ASCII text characters each have a numeric code that can be expressed in hexadecimal.
Hexadecimal:
Hexadecimal representation of text is used in programming, networking, and data analysis.
How to Convert ASCII Text to Hexadecimal — Formula:
For each character: hex = charCode.toString(16).padStart(2, "0").toUpperCase().
Example: "Hello" → 48 65 6C 6C 6F.
Technical Details:
Common ASCII hex values: A=41, Z=5A, a=61, z=7A, 0=30, 9=39, space=20, newline=0A. This encoding is used in hex editors, network protocol analysis, and debugging.
Ascii To Hex Converter:
Convert text to hexadecimal byte values. Each character becomes a 2-digit hex code.
ASCII Encoding: Text → Numbers → Binary
How to Convert ASCII Text to Hexadecimal
- Take the ascii text value
- Apply the conversion formula
- Get the hexadecimal result
ASCII Text to Hex, Binary Conversion Table
| ASCII Character | Hexadecimal | Binary |
|---|---|---|
| NUL | 00 | 00000000 |
| SOH | 01 | 00000001 |
| STX | 02 | 00000010 |
| ETX | 03 | 00000011 |
| EOT | 04 | 00000100 |
| ENQ | 05 | 00000101 |
| ACK | 06 | 00000110 |
| BEL | 07 | 00000111 |
| BS | 08 | 00001000 |
| HT | 09 | 00001001 |
| LF | 0A | 00001010 |
| VT | 0B | 00001011 |
| FF | 0C | 00001100 |
| CR | 0D | 00001101 |
| SO | 0E | 00001110 |
| SI | 0F | 00001111 |
| DLE | 10 | 00010000 |
| DC1 | 11 | 00010001 |
| DC2 | 12 | 00010010 |
| DC3 | 13 | 00010011 |
| DC4 | 14 | 00010100 |
| NAK | 15 | 00010101 |
| SYN | 16 | 00010110 |
| ETB | 17 | 00010111 |
| CAN | 18 | 00011000 |
| EM | 19 | 00011001 |
| SUB | 1A | 00011010 |
| ESC | 1B | 00011011 |
| FS | 1C | 00011100 |
| GS | 1D | 00011101 |
| RS | 1E | 00011110 |
| US | 1F | 00011111 |
| Space | 20 | 00100000 |
| ! | 21 | 00100001 |
| " | 22 | 00100010 |
| # | 23 | 00100011 |
| $ | 24 | 00100100 |
| % | 25 | 00100101 |
| & | 26 | 00100110 |
| ' | 27 | 00100111 |
| ( | 28 | 00101000 |
| ) | 29 | 00101001 |
| * | 2A | 00101010 |
| + | 2B | 00101011 |
| , | 2C | 00101100 |
| - | 2D | 00101101 |
| . | 2E | 00101110 |
| / | 2F | 00101111 |
| 0 | 30 | 00110000 |
| 1 | 31 | 00110001 |
| 2 | 32 | 00110010 |
| 3 | 33 | 00110011 |
| 4 | 34 | 00110100 |
| 5 | 35 | 00110101 |
| 6 | 36 | 00110110 |
| 7 | 37 | 00110111 |
| 8 | 38 | 00111000 |
| 9 | 39 | 00111001 |
| : | 3A | 00111010 |
| ; | 3B | 00111011 |
| < | 3C | 00111100 |
| = | 3D | 00111101 |
| > | 3E | 00111110 |
| ? | 3F | 00111111 |
| @ | 40 | 01000000 |
| A | 41 | 01000001 |
| B | 42 | 01000010 |
| C | 43 | 01000011 |
| D | 44 | 01000100 |
| E | 45 | 01000101 |
| F | 46 | 01000110 |
| G | 47 | 01000111 |
| H | 48 | 01001000 |
| I | 49 | 01001001 |
| J | 4A | 01001010 |
| K | 4B | 01001011 |
| L | 4C | 01001100 |
| M | 4D | 01001101 |
| N | 4E | 01001110 |
| O | 4F | 01001111 |
| P | 50 | 01010000 |
| Q | 51 | 01010001 |
| R | 52 | 01010010 |
| S | 53 | 01010011 |
| T | 54 | 01010100 |
| U | 55 | 01010101 |
| V | 56 | 01010110 |
| W | 57 | 01010111 |
| X | 58 | 01011000 |
| Y | 59 | 01011001 |
| Z | 5A | 01011010 |
| [ | 5B | 01011011 |
| \ | 5C | 01011100 |
| ] | 5D | 01011101 |
| ^ | 5E | 01011110 |
| _ | 5F | 01011111 |
| ` | 60 | 01100000 |
| a | 61 | 01100001 |
| b | 62 | 01100010 |
| c | 63 | 01100011 |
| d | 64 | 01100100 |
| e | 65 | 01100101 |
| f | 66 | 01100110 |
| g | 67 | 01100111 |
| h | 68 | 01101000 |
| i | 69 | 01101001 |
| j | 6A | 01101010 |
| k | 6B | 01101011 |
| l | 6C | 01101100 |
| m | 6D | 01101101 |
| n | 6E | 01101110 |
| o | 6F | 01101111 |
| p | 70 | 01110000 |
| q | 71 | 01110001 |
| r | 72 | 01110010 |
| s | 73 | 01110011 |
| t | 74 | 01110100 |
| u | 75 | 01110101 |
| v | 76 | 01110110 |
| w | 77 | 01110111 |
| x | 78 | 01111000 |
| y | 79 | 01111001 |
| z | 7A | 01111010 |
| { | 7B | 01111011 |
| | | 7C | 01111100 |
| } | 7D | 01111101 |
| ~ | 7E | 01111110 |
| DEL | 7F | 01111111 |
Frequently Asked Questions
How do I convert ASCII Text to Hexadecimal?
For each character: hex = charCode.toString(16).padStart(2, "0").toUpperCase().
What is the ASCII Text number system?
ASCII text characters each have a numeric code that can be expressed in hexadecimal.
What is the Hexadecimal number system?
Hexadecimal representation of text is used in programming, networking, and data analysis.
Where is ASCII Text to Hexadecimal conversion used?
Common ASCII hex values: A=41, Z=5A, a=61, z=7A, 0=30, 9=39, space=20, newline=0A. This encoding is used in hex editors, network protocol analysis, and debugging.
Can I convert large ascii text numbers?
Yes. This converter handles numbers of any practical size. For very large numbers, the conversion is performed using arbitrary-precision arithmetic to ensure accuracy.
How to Convert ASCII to Hexadecimal (Characters to Hex Codes)
Converting ASCII characters to hex is used when constructing network packets, writing binary protocols, creating hex dumps, and working with URL encoding. Each ASCII character maps to a 2-digit hex code between 0x00 and 0x7F. This is the reverse of reading a hex dump — you are creating one.
- Look up each character's ASCII decimal value.
- Convert the decimal value to a 2-digit hexadecimal number.
- For quick mental conversion: high nibble = value ÷ 16, low nibble = value mod 16.
- Concatenate all hex pairs (optionally space-separated for readability).
- Example: "OK" → 79, 75 → 4F 4B.
ASCII to Hex: Common Characters
Characters you will frequently need to convert to hex for protocol work:
| Input | Output |
|---|---|
| Space | 0x20 |
| ! | 0x21 |
| # | 0x23 |
| % | 0x25 |
| / | 0x2F |
| 0 | 0x30 |
| : | 0x3A |
| ? | 0x3F |
| A | 0x41 |
| a | 0x61 |
| { | 0x7B |
| } | 0x7D |
Solved Examples: ASCII to Hex
Question 1: Encode the HTTP method "POST" in hex for a raw socket transmission.
Solution:
P = 80 = 0x50
O = 79 = 0x4F
S = 83 = 0x53
T = 84 = 0x54
Answer: "POST" = 50 4F 53 54 in hex — these are the first 4 bytes of an HTTP POST request.
Question 2: URL-encode the string "a b" (with a space) using hex.
Solution:
a = 0x61 (no encoding needed, alphanumeric)
space = 0x20 → %20
b = 0x62 (no encoding needed)
Answer: "a b" URL-encodes to "a%20b" — the space character becomes its hex representation preceded by %.
Question 3: Generate the hex for a JSON null terminator: {"x":null}\0
Solution:
{=7B, "=22, x=78, "=22, :=3A
n=6E, u=75, l=6C, l=6C
}=7D, \0=00
Answer: Full hex: 7B 22 78 22 3A 6E 75 6C 6C 7D 00 — the trailing 00 is the NULL terminator.
Practice: ASCII to Hex
Try solving these on your own to test your understanding:
- Convert "GET" to hex. (Answer: 47 45 54)
- What is the hex for the @ symbol? (Answer: 0x40)
- Convert "127.0.0.1" to hex. (Answer: 31 32 37 2E 30 2E 30 2E 31)
- What is the hex for a newline \n? (Answer: 0x0A)
- Convert "true" to hex. (Answer: 74 72 75 65)
- What hex value represents the colon character? (Answer: 0x3A)
Building Network Packets with Hex
When crafting raw network packets (using tools like Scapy, netcat, or writing socket code), you specify data in hex. An HTTP request "GET / HTTP/1.1\r\n" becomes 47 45 54 20 2F 20 48 54 54 50 2F 31 2E 31 0D 0A. Each ASCII character is one hex byte. Understanding this mapping lets you read Wireshark captures, construct protocol payloads, and debug network issues at the byte level.
Hex Escapes in Programming Languages
Most languages support hex escapes in strings: C/C++ uses \x41 for "A", Python uses \x41 or bytes.fromhex("41"), JavaScript uses \x41 or String.fromCharCode(0x41). When dealing with binary protocols or non-printable characters, hex escapes are essential: \x00 (NULL), \x0A (newline), \x1B (ESC for terminal colors). These are all ASCII-to-hex conversions embedded directly in source code.
Key Takeaways
- Each ASCII character = one 2-digit hex code (0x00 to 0x7F).
- Uppercase letters: 0x41-0x5A; lowercase: 0x61-0x7A; digits: 0x30-0x39.
- Add 0x20 to uppercase hex to get lowercase (A=41, a=61).
- URL encoding uses %XX format where XX is the ASCII hex code.
- Programming languages support \xNN for hex character escapes.
- Network debugging requires reading and writing ASCII as hex bytes.