ASCII to Hex Converter — Encode Text as Hex Byte Sequences
Last updated:
Convert plain ASCII text into its hexadecimal byte representation. Each character becomes one byte, written as exactly two upper-case hex digits with no separator — the canonical shape expected by hex dumps, protocol fields, C string literals, and most debugger input. Strict 7-bit ASCII means any input outside 0-127 stops conversion with the position flagged.
ASCII ⇄ Hex Converter
How ASCII to hex encoding works
The converter reads the input string character by character. For each character, it takes the character's numeric code point — for example, "A" is 65, "z" is 122, space is 32 — and formats that number as a two-digit base-16 string with leading zero if needed. Values are zero-padded so single-digit byte values like 0x05 always show as 05, never bare 5. The result is a continuous hex stream where every two characters map back to one ASCII byte.
Quick examples
| ASCII | Hex |
|---|---|
| A | 41 |
| Hi | 4869 |
| Hello | 48656C6C6F |
| Hello, World! | 48656C6C6F2C20576F726C6421 |
| (space) | 20 |
| (tab) | 09 |
How to use
- Type or paste ASCII text into Input. Any character with code > 127 (emoji, é, 中, smart quotes) is rejected with the position flagged.
- The hex byte stream appears in Output, upper-case, with no separator. Length is exactly 2× the input.
- To decode hex back, click Hex → ASCII at the top, or use Swap.
- Click Copy to grab the hex string. All work runs in your browser; nothing is uploaded.
Real-world use cases
- Writing C / Python / Rust hex literals. A string like
"Hello"becomes"\x48\x65\x6C\x6C\x6F"when each character is escaped as a hex byte. Compose the bare hex here, then prefix each pair with\xin your editor. Useful when a literal needs to survive copy-paste through compilers, configuration files, or terminals that mishandle high-bit characters. - Filling protocol fields. Many wire protocols specify field contents in hex: BLE characteristic values, HTTP header value escapes, Redis RESP commands embedded in test fixtures, raw socket payloads. Producing the hex form of an ASCII command keeps the test data byte-exact and language-independent.
- JSON / SQL hex-encoded blobs. PostgreSQL's
\xblob syntax, MySQL'sUNHEX(), and many JSON dialects accept hex strings as binary content. Converting a known-good ASCII string to hex gives a deterministic blob value that round-trips losslessly through systems that might otherwise re-interpret string encoding. - URL / form encoding inspection. URL percent-encoding ("%48%65%6C%6C%6F") is the same byte values as hex with
%separators. Producing the bare hex first, then mapping every two characters to%XX, is a quick way to manually verify what a URL encoder would emit. - Hash and HMAC input prep. Some hash and HMAC API calls take a hex-encoded message instead of raw bytes. When you have an ASCII password or string to hash, converting it here gives the exact hex input the API expects, with no character-encoding ambiguity.
- Pairing with hex to binary. After encoding ASCII to hex here, expanding the hex into 4-bit nibbles via the binary converter shows you the bit pattern of each character — useful for teaching, CTF puzzles, and bit-level protocol design.
Why upper-case, no separators
The convention of upper-case A-F in hex dates back to IBM's System/360 standardisation in the mid-1960s and remained the default in nearly every debugger, assembler, and protocol document since. The reason is mostly legibility in cramped fixed-width fonts: lower-case b can blur with 6, and d with 0, whereas upper-case glyphs read cleanly even at small point sizes. This converter follows that convention so the output drops straight into most engineering contexts without case-mangling.
The "no separators" choice is similarly historical. A hex dump uses spaces between bytes for human reading, but the actual hex literal in code, configuration, and APIs is almost always a continuous string — 0x48656C6C6F not 0x48 65 6C 6C 6F. Outputting the canonical, separator-free form means the result can be used directly in most contexts; if you need formatted output, splitting every two characters is a single regex away. Going the other direction, hex to ASCII re-decodes either format because whitespace is stripped on input.
Worked examples
Single character: A → 41
"A" is ASCII code 65, which is 0x41 in hex. Always two digits with leading zero where needed, so even small values like 05 or 0A stay byte-aligned.
Common phrase: Hello, World!
Thirteen characters encode to twenty-six hex digits: 48656C6C6F2C20576F726C6421. Notice the comma (2C), the space (20), and the exclamation mark (21) all live inside the ASCII printable range and encode the same way as letters.
Control characters: newline + tab → 0A09
A single newline character (\n, code 10) encodes to 0A. A tab (\t, code 9) is 09. These are invisible in the output of the reverse converter but show up clearly as hex bytes. Useful when assembling protocol commands like HTTP that require literal \r\n sequences.
Common pitfalls
- Non-ASCII characters. Any character with code > 127 fails: accented letters (é, ü, ñ), CJK ideographs (中, 日, 한), emoji (😀), smart quotes (“ ”), em-dashes (—), and most copy-pastes from word processors. The error names the character, its code point, and its position so you can locate and replace it.
- Trailing whitespace stripped on copy. If your text ends in spaces or newlines, encoding includes those bytes ("Hi " →
486920, not4869). Trim before encoding if you do not want them in the output, since the reverse converter will not silently drop them either. - Wanting hex with separators. The output has no spaces or commas between bytes. To produce
48 65 6C 6C 6F-style dump format, split the result every 2 characters with a regex or pipe throughfold -w2in a shell. - Confusing this with binary encoding. "ASCII to hex" gives 2 hex characters per byte. "ASCII to binary" (different tool) gives 8 bits per byte. Two hex characters and 8 bits represent the same byte value — pick whichever shape your downstream tool expects.
- Empty input. An empty string encodes to an empty hex string. Some downstream tools treat an empty hex blob as a null value rather than a zero-length value — worth verifying if you are filling a database column with the result.
Frequently asked questions
Why does my input with é or emoji fail?
This tool is strict 7-bit ASCII. Any character with a code point above 127 — accented Latin letters, CJK ideographs, emoji, smart quotes — falls outside the ASCII table and is rejected. If you need a byte-level encoding for those, route through the binary-to-text page with UTF-8 (each emoji becomes multiple bytes) and then convert the resulting binary to hex, or expose the UTF-8 byte sequence via a small script.
Is the output upper-case or lower-case?
Upper-case A-F is the default — matching assembly listings, hex dumps, MAC addresses, and most debugger output. If you need lower-case for a specific format (some JWT or CSS-color conventions prefer it), copy the result and run a one-liner like `pbpaste | tr A-F a-f`.
Are there separators between bytes in the output?
No. The hex stream is continuous — no spaces, no colons, no 0x prefix. If you need byte separators for a hex dump style ("48 65 6C 6C 6F"), split the output manually every 2 characters, or paste it back into the reverse converter to see byte boundaries.
How does this differ from URL encoding (percent-encoding)?
URL encoding wraps the same hex byte values with a percent sign ("Hello" → "%48%65%6C%6C%6F") and only encodes unsafe characters by default. This tool encodes every character and outputs the bare hex digits. The byte values themselves are identical, so converting between the two is purely cosmetic (add/remove the % signs).
What is the byte count of the output?
Exactly twice the input character count, because each ASCII character is one byte and each byte is two hex digits. A 50-character string becomes a 100-character hex string. There is no overhead or framing.
How do I produce a C / Python hex literal from the output?
Insert "\x" before every two hex digits. "Hello" → output "48656C6C6F" → literal "\x48\x65\x6C\x6C\x6F". Many editors can do this with a regex replace (find "(..)", replace with "\x$1"). The values are byte-identical to what you would get from any other ASCII-to-hex tool.