ASCII Text to Hex Converter
To use ASCII text to hex converter, type an ASCII value e.g. "King Kong" and click on the Convert button and you will get the hexadecimal converted value "4B 69 6E 67 20 4B 6F 6E 67". Space is also a valid ASCII char and it is converted to hex value of 20 (decimal: 32).
ASCII Text to Hex Conversion:
- Why Convert ASCII to Hex
- How to Convert ASCII to Hex
- ASCII Text to Hex Examples
- ASCII Table
- FAQs (ASCII Text To Hex Conversion)
Why Convert ASCII To Hex
Each ASCII character is associated with a decimal number, which can also be represented in binary or hexadecimal. Converting ASCII text to hex means translating each character into a two-digit hex number corresponding to its ASCII decimal code. Hex is base-16 number system and it can represent binary data more compactly. This conversion is mostly used in data encoding, cryptography and embedded system applications.
Hex byte "5F" can be expressed as:
(5 × 161) + (15 × 160) = (80 + 15) = 95 (decimal).
How to Convert ASCII Text to Hex
Consider the following steps:
Step 1: Identify the ASCII decimal value of each character from ASCII table.
Step 2: Convert all decimal values to hex bytes.
Step 2: The final output is the hexadecimal value of the text string and all hex bytes are separated by space delimiter.
ASCII Text to Hex Examples
Example 1: Convert the text "friend" to hex value.
ASCII | Decimal | Decimal to Hex | Hex |
---|---|---|---|
f | 102 | (6×161) + (6×160) = 102 | 66 |
r | 114 | (7×161) + (2×160) = 114 | 72 |
i | 105 | (6×161) + (9×160) = 105 | 69 |
e | 101 | (6×161) + (5×160) = 101 | 65 |
n | 110 | (6×161) + (14×160) = 110 | 6E |
d | 100 | (6×161) + (4×160) = 100 | 64 |
Example 2: Convert the text "United States & China" to hex value.
ASCII | Decimal | Decimal to Hex | Hex |
---|---|---|---|
U | 85 | (5×161) + (5×160) = 85 | 55 |
n | 110 | (6×161) + (14×160) = 110 | 6E |
i | 105 | (6×161) + (9×160) = 105 | 69 |
t | 116 | (7×161) + (4×160) = 116 | 74 |
e | 101 | (6×161) + (5×160) = 101 | 65 |
d | 100 | (6×161) + (4×160) = 100 | 64 |
space | 32 | (2×161) + (0×160) = 32 | 20 |
S | 83 | (5×161) + (3×160) = 83 | 53 |
t | 116 | (7×161) + (4×160) = 116 | 74 |
a | 97 | (6×161) + (1×160) = 97 | 61 |
t | 116 | (7×161) + (4×160) = 116 | 74 |
e | 101 | (6×161) + (5×160) = 101 | 65 |
s | 115 | (7×161) + (3×160) = 115 | 73 |
space | 32 | (2×161) + (0×160) = 32 | 20 |
& | 38 | (2×161) + (6×160) = 38 | 26 |
space | 32 | (2×161) + (0×160) = 32 | 20 |
C | 67 | (4×161) + (3×160) = 67 | 43 |
h | 104 | (6×161) + (8×160) = 104 | 68 |
i | 105 | (6×161) + (9×160) = 105 | 69 |
n | 110 | (6×161) + (14×160) = 110 | 6E |
a | 97 | (6×161) + (1×160) = 97 | 61 |
Example 3: Convert text "Math +-/" to hex value.
ASCII | Decimal | Decimal to Hex | Hex |
---|---|---|---|
M | 77 | (4×161) + (13×160) = 77 | 4D |
a | 97 | (6×161) + (1×160) = 97 | 61 |
t | 116 | (7×161) + (4×160) = 116 | 74 |
h | 104 | (6×161) + (8×160) = 104 | 68 |
space | 32 | (2×161) + (0×160) = 32 | 20 |
+ | 43 | (2×161) + (11×160) = 43 | 2B |
- | 45 | (2×161) + (13×160) = 45 | 2D |
/ | 47 | (2×161) + (15×160) = 47 | 2F |
Example 4: Convert text "HI $$/$" to hex value.
ASCII | Decimal | Decimal to Hex | Hex |
---|---|---|---|
H | 72 | (4×161) + (8×160) = 72 | 48 |
I | 73 | (4×161) + (9×160) = 73 | 49 |
space | 32 | (2×161) + (0×160) = 32 | 20 |
$ | 36 | (2×161) + (4×160) = 36 | 24 |
$ | 36 | (2×161) + (4×160) = 36 | 24 |
/ | 47 | (2×161) + (15×160) = 47 | 2F |
$ | 36 | (2×161) + (4×160) = 36 | 24 |
Frequently Ask Questions: ASCII Text to Hex Conversion
Q1: Can we convert the space to hex value?
Yes the space can be converted to a hex value of 20 and decimal value of 32.
Q2: What is the difference between ASCII and Unicode hex conversion?
ASCII uses 1 byte per character, while Unicode (like UTF-8) can use multiple bytes, so the hex may have more digits for non-ASCII characters.
Q3: Why is ASCII to hex preferred over binary?
Hexadecimal is more compact and readable, representing every 4 bits as a single digit. While computers operate in binary, hex offers a more compact and user-friendly way to represent the underlying binary data.
Q4: How to convert 'A' to hex value?
You can use ASCII table: 'A' = (65)10 = 4×161 + 1×160 = (41)16
Q5: What is the hex representation of newline (\n) or horizontal tab (\t)?
The newline or line feed (LF) (\n) has the hex ASCII code of "0x0A" (decimal: 10) while the horizontal tab (HT) or (\t) has the hex value of "0x09" (decimal: 09).
Related Conversions
Please find the related numeric conversions.