EasyUnitConverter.com

Text To Hex Converter

Enter the text value to convert to hexadecimal or Hexadecimal to Text.

10
10
10
16

About Text To Hex Converter

Our free online text to hex converter tool provides instant and accurate conversion between text and hexadecimal formats.

How to Convert Text to Hex

Convert text to hex ASCII code:

  1. Get character from the text string
  2. Get decimal code of character from ASCII table
  3. Convert decimal to hex byte
  4. Continue with next character

Example

Convert "Plant trees" text to hex ASCII code:

"P" => 80 = 5×16¹+0×16⁰ = 50₁₆

"l" => 108 = 6×16¹+12×16⁰ = 6C₁₆

"a" => 97 = 6×16¹+1×16⁰ = 61₁₆

"n" => 110 = 6×16¹+14×16⁰ = 6E₁₆

"t" => 116 = 7×16¹+4×16⁰ = 74₁₆

Result: "50 6C 61 6E 74 20 74 72 65 65 73"

Frequently Asked Questions

How to convert ASCII Text to Hex?

  1. Get character from text
  2. Get ASCII code of character from ASCII table
  3. Convert decimal to hex byte
  4. Continue with next character

How to convert 'A' character to hex?

Use ASCII table: 'A' = 65₁₀ = 4×16+1 = 41₁₆

How to convert '0' character to hex?

Use ASCII table: '0' = 48₁₀ = 3×16+0 = 30₁₆

ASCII Text to Hex, Binary Conversion Table

ASCII CharacterHexadecimalBinary
NUL0000000000
SOH0100000001
STX0200000010
ETX0300000011
EOT0400000100
ENQ0500000101
ACK0600000110
BEL0700000111
BS0800001000
HT0900001001
LF0A00001010
VT0B00001011
FF0C00001100
CR0D00001101
SO0E00001110
SI0F00001111
DLE1000010000
DC11100010001
DC21200010010
DC31300010011
DC41400010100
NAK1500010101
SYN1600010110
ETB1700010111
CAN1800011000
EM1900011001
SUB1A00011010
ESC1B00011011
FS1C00011100
GS1D00011101
RS1E00011110
US1F00011111
Space2000100000
!2100100001
"2200100010
#2300100011
$2400100100
%2500100101
&2600100110
'2700100111
(2800101000
)2900101001
*2A00101010
+2B00101011
,2C00101100
-2D00101101
.2E00101110
/2F00101111
03000110000
13100110001
23200110010
33300110011
43400110100
53500110101
63600110110
73700110111
83800111000
93900111001
:3A00111010
;3B00111011
<3C00111100
=3D00111101
>3E00111110
?3F00111111
@4001000000
A4101000001
B4201000010
C4301000011
D4401000100
E4501000101
F4601000110
G4701000111
H4801001000
I4901001001
J4A01001010
K4B01001011
L4C01001100
M4D01001101
N4E01001110
O4F01001111
P5001010000
Q5101010001
R5201010010
S5301010011
T5401010100
U5501010101
V5601010110
W5701010111
X5801011000
Y5901011001
Z5A01011010
[5B01011011
\5C01011100
]5D01011101
^5E01011110
_5F01011111
`6001100000
a6101100001
b6201100010
c6301100011
d6401100100
e6501100101
f6601100110
g6701100111
h6801101000
i6901101001
j6A01101010
k6B01101011
l6C01101100
m6D01101101
n6E01101110
o6F01101111
p7001110000
q7101110001
r7201110010
s7301110011
t7401110100
u7501110101
v7601110110
w7701110111
x7801111000
y7901111001
z7A01111010
{7B01111011
|7C01111100
}7D01111101
~7E01111110
DEL7F01111111

How to Convert Text to Hex (Encoding Text as Hexadecimal)

Text-to-hex conversion is used in programming for string constants, constructing binary protocols, creating hex-encoded payloads, and debugging. When you need to represent text as raw bytes in code or documentation, hex encoding provides a compact, unambiguous representation that works for both printable and non-printable characters.

  1. Take each character from the text string.
  2. Look up its ASCII/UTF-8 decimal code.
  3. Convert the decimal code to a 2-digit hex value.
  4. Optionally separate hex pairs with spaces or prefix with 0x.
  5. Example: "Hi!" → H=48, i=69, !=21 → "48 69 21".
💡 Tip: For lowercase letters: subtract 'a' (97=0x61) and add 0x61. For 'c': position 2 + 0x61 = 0x63. For uppercase: position + 0x41. For digits: character + 0x30. These formulas eliminate table lookups.

Text to Hex: Common Strings

Frequently converted text strings and their hex representations:

InputOutput
GET47 45 54
POST50 4F 53 54
HTTP48 54 54 50
null6E 75 6C 6C
true74 72 75 65
\r\n0D 0A
ping70 69 6E 67
root72 6F 6F 74
admin61 64 6D 69 6E
200 OK32 30 30 20 4F 4B

Solved Examples: Text to Hex

Question 1: Encode the string "Content-Type: application/json\r\n" in hex for an HTTP header.

Solution:

C=43, o=6F, n=6E, t=74, e=65, n=6E, t=74

-=2D, T=54, y=79, p=70, e=65, :=3A, space=20

a=61, p=70, p=70, l=6C, i=69, c=63, a=61, t=74, i=69, o=6F, n=6E

/=2F, j=6A, s=73, o=6F, n=6E

\r=0D, \n=0A

Answer: The header in hex: 43 6F 6E 74 65 6E 74 2D 54 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A.

Question 2: Hex-encode the SQL string "SELECT * FROM users" for a protocol payload.

Solution:

S=53, E=45, L=4C, E=45, C=43, T=54

space=20, *=2A, space=20

F=46, R=52, O=4F, M=4D, space=20

u=75, s=73, e=65, r=72, s=73

Answer: "SELECT * FROM users" = 53 45 4C 45 43 54 20 2A 20 46 52 4F 4D 20 75 73 65 72 73.

Question 3: Encode the JSON {"id":1} in hex.

Solution:

{=7B, "=22, i=69, d=64, "=22

:=3A, 1=31

}=7D

Answer: {"id":1} = 7B 22 69 64 22 3A 31 7D — 8 bytes of JSON payload.

Practice: Text to Hex

Try solving these on your own to test your understanding:

  1. Convert "Hello" to hex. (Answer: 48 65 6C 6C 6F)
  2. Convert "EOF" to hex. (Answer: 45 4F 46)
  3. What is the hex for a tab character? (Answer: 09)
  4. Convert ":80" (a port number) to hex. (Answer: 3A 38 30)
  5. Convert "OK\n" to hex. (Answer: 4F 4B 0A)
  6. Convert "{}" to hex. (Answer: 7B 7D)

Hex Encoding in APIs and Web Development

Web APIs frequently hex-encode data: HTTP headers are text converted to bytes, WebSocket frames encode payloads in binary (viewed as hex), and Content-Length headers tell receivers how many hex-byte pairs to expect. When building API clients with raw sockets, you construct the entire request as hex: the method, headers, CRLF separators, and body are all text→hex conversions concatenated together.

Creating Test Payloads and Fixtures

QA engineers and penetration testers create test payloads in hex to ensure exact byte sequences. A boundary injection test might require precise CRLF placement: "line1\r\ninjected-header: value\r\n" becomes a hex string that tools inject verbatim. Unlike text input (which may be re-encoded by intermediaries), hex payloads guarantee byte-exact transmission, making them essential for protocol-level testing.

Key Takeaways

  • Each text character becomes a 2-digit hex code.
  • Common: space=20, \r=0D, \n=0A, \t=09.
  • Lowercase starts at 0x61, uppercase at 0x41, digits at 0x30.
  • HTTP requests are text converted to sequential hex bytes.
  • Hex encoding guarantees byte-exact payloads for testing and debugging.
  • String length in characters = number of hex pairs for pure ASCII text.

Related Number System Converters: