Quick answer: String to hex converts plain text into its
hexadecimal byte representation. Hello
becomes 48656c6c6f — each
character's byte value written as two hex digits. Paste your text above,
click Convert, copy the hex output. Conversion happens in your browser.
What is hex encoding?
Hex (short for hexadecimal) is a base-16 number system using digits
0–9 and a–f. Each hex digit represents 4 bits, so
two hex digits represent exactly one byte. Encoding a string to hex means
replacing every character with its underlying byte value, written in this
base-16 form.
It's the easiest human-readable representation of binary data and shows up
everywhere: hash digests (sha256: 5e884898...), network
packets (0d 0a for CRLF), color codes (#ff5733),
memory addresses, and forensic dumps.
How string-to-hex conversion works
- Take the input string one character at a time.
- Look up each character's numeric code (its UTF-16 code unit, or for ASCII chars, the same as the ASCII code).
- Convert that number to base-16 (hex).
- Pad to 2 digits with a leading zero if needed.
- Concatenate all pairs into the final hex string.
For example, Hi! becomes:
H→ 72 →48i→ 105 →69!→ 33 →21
Result: 486921.
Examples
| String input | Hex output | Notes |
|---|---|---|
| Hello | 48656c6c6f | 5 chars → 10 hex digits |
| Hello, world! | 48656c6c6f2c20776f726c6421 | Spaces and punctuation included |
| a | 61 | Lowercase 'a' = 0x61 |
| A | 41 | Uppercase 'A' = 0x41 |
| 123 | 313233 | Digits 1-3 = 0x31-0x33 |
Hex vs. base64 vs. URL encoding
| Encoding | Overhead | Best for |
|---|---|---|
| Hex / base16 | 2× (100%) | Hashes, debugging, hex dumps, color codes |
| Base64 | ~1.33× (33%) | Email attachments, JWT, data URIs |
| Base32 | 1.6× (60%) | Case-insensitive identifiers, OTP secrets |
| URL encoding | 1× to 3× | Query parameters, form data |
When to use string-to-hex
- Generating test data for hex parsers and decoders.
- Embedding strings as byte arrays in C/C++ source code or firmware.
- Building network packets for low-level protocol testing (Wireshark playback, custom raw sockets).
- Debugging encoding issues — converting suspicious text to hex reveals invisible characters and byte-order marks.
- Producing input for CTF challenges or steganography puzzles.
- Quickly checking ASCII vs UTF-8 byte counts — hex output length / 2 = byte count.
Doing it in code
JavaScript
Array.from("Hello").map(c => c.charCodeAt(0).toString(16).padStart(2, "0")).join("")
// "48656c6c6f" Python
"Hello".encode("utf-8").hex()
# "48656c6c6f" Bash
echo -n "Hello" | xxd -p
# 48656c6c6f Node.js
Buffer.from("Hello", "utf-8").toString("hex")
// "48656c6c6f" Related tools
- Hex to String Converter — reverse direction
- String to Binary — base-2 encoding
- Base64 Encode — more compact encoding
- Base32 Encode — case-insensitive encoding
Frequently asked questions
What is string to hex conversion?
String to hex conversion encodes each character of a text string as its byte value in hexadecimal (base-16). For example, "Hello" becomes "48656c6c6f" — "H" is byte 0x48, "e" is 0x65, and so on. The output is a sequence of two-digit hex pairs, one pair per byte.
How do I convert a string to hex?
Type or paste your text into the input field and click Convert. The tool walks through the string character by character, looks up each one's character code, formats it as two hex digits (zero-padded), and joins them together.
Why does my hex output look longer than expected?
Each character produces 2 hex digits. So a 10-character string produces a 20-character hex string. Multi-byte UTF-8 characters (like "é" or emoji) produce more — "é" encodes as "c3a9" (4 hex digits), and a typical emoji encodes as 6–8 hex digits.
Is hex output uppercase or lowercase?
This tool outputs lowercase hex (e.g. a-f). Both forms are valid and equivalent for decoding — most modern systems use lowercase. If you need uppercase, transform the output with the Case Converter.
What's the difference between hex encoding and base64?
Both convert binary data into a printable text representation. Base64 is more compact (4 base64 chars per 3 bytes ≈ 33% overhead) and is the default for email attachments and JWTs. Hex is simpler (2 chars per byte = 100% overhead) but easier to read and is the default for hashes, network captures, and hex dumps.
Where is string-to-hex encoding used?
Common uses: writing test data for hex parsers, generating sample input for debugging, embedding text in source code as byte arrays, creating fixed-size identifiers, building network packet payloads, and producing data for forensic analysis or CTF challenges.
Are my strings sent to a server?
No. The encoding runs locally in your browser using JavaScript. Your input never leaves your device, isn't logged, and isn't stored.