Text To Hex Converter
Enter the text value to convert to hexadecimal or Hexadecimal to Text.
Related Number System Converters:
About Text To Hex Converter
Our free online text to hex converter tool provides instant and accurate conversion between text and hexadecimal formats.
ASCII Encoding: Text → Numbers → Binary
How to Convert Text to Hex
Convert text to hex ASCII code:
- Get character from the text string
- Get decimal code of character from ASCII table
- Convert decimal to hex byte
- 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?
- Get character from text
- Get ASCII code of character from ASCII table
- Convert decimal to hex byte
- 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 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 |
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.
- Take each character from the text string.
- Look up its ASCII/UTF-8 decimal code.
- Convert the decimal code to a 2-digit hex value.
- Optionally separate hex pairs with spaces or prefix with 0x.
- Example: "Hi!" → H=48, i=69, !=21 → "48 69 21".
Text to Hex: Common Strings
Frequently converted text strings and their hex representations:
| Input | Output |
|---|---|
| GET | 47 45 54 |
| POST | 50 4F 53 54 |
| HTTP | 48 54 54 50 |
| null | 6E 75 6C 6C |
| true | 74 72 75 65 |
| \r\n | 0D 0A |
| ping | 70 69 6E 67 |
| root | 72 6F 6F 74 |
| admin | 61 64 6D 69 6E |
| 200 OK | 32 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:
- Convert "Hello" to hex. (Answer: 48 65 6C 6C 6F)
- Convert "EOF" to hex. (Answer: 45 4F 46)
- What is the hex for a tab character? (Answer: 09)
- Convert ":80" (a port number) to hex. (Answer: 3A 38 30)
- Convert "OK\n" to hex. (Answer: 4F 4B 0A)
- 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.