ASCII to Hex Converter
Convert between ASCII text and hexadecimal values with a built-in reference table
Hex Format
Type ASCII text on the left or hex values on the right — the other side updates automatically. Supports any format: space-separated, comma-separated, or 0x-prefixed hex bytes.
You need to find the hex value of a control character for a serial protocol configuration. Or you’re debugging a terminal emulator and need to confirm that the escape sequence \x1B[31m corresponds to the right bytes. Or you’re writing embedded firmware and need to convert between ASCII character literals and their numeric representations. This tool maps ASCII characters to their hex, decimal, and binary values — both directions.
What Is ASCII?
ASCII (American Standard Code for Information Interchange) is a 7-bit character encoding standard published in 1963 and last revised in 1986 (ANSI X3.4-1986). It defines 128 characters:
- 0–31 and 127: 33 control characters (non-printable) — null (
NUL), tab (HT), newline (LF), carriage return (CR), escape (ESC), delete (DEL), and others - 32–126: 95 printable characters — space, digits 0–9, uppercase A–Z, lowercase a–z, and punctuation
ASCII is the foundation of virtually every modern character encoding. UTF-8 is backward-compatible with ASCII: every valid ASCII byte is also a valid UTF-8 byte with the same meaning. Latin-1 (ISO-8859-1) extends ASCII with 128 additional characters in the 128–255 range.
The ASCII Table
| Dec | Hex | Char | Dec | Hex | Char | Dec | Hex | Char |
|---|---|---|---|---|---|---|---|---|
| 32 | 20 | SP | 48 | 30 | 0 | 65 | 41 | A |
| 33 | 21 | ! | 49 | 31 | 1 | 66 | 42 | B |
| 34 | 22 | ” | 50 | 32 | 2 | 67 | 43 | C |
| 35 | 23 | # | 51 | 33 | 3 | 90 | 5A | Z |
| 36 | 24 | $ | 52 | 34 | 4 | 97 | 61 | a |
| 37 | 25 | % | 53 | 35 | 5 | 98 | 62 | b |
| 46 | 2E | . | 57 | 39 | 9 | 122 | 7A | z |
The full table has 128 entries. This tool displays the complete table as a reference alongside the conversion.
ASCII vs Unicode
ASCII defines only 128 characters — enough for English but not for any other language. Unicode (the standard behind UTF-8, UTF-16, and UTF-32) defines over 149,000 characters covering every modern writing system plus historical scripts, mathematical symbols, and emoji.
The key relationship: ASCII is a proper subset of Unicode. The first 128 Unicode codepoints (U+0000 through U+007F) are identical to ASCII. This means:
- Any ASCII text is valid UTF-8
- Any ASCII hex value is the same in UTF-8
- Characters beyond ASCII (128+) require multi-byte encoding in UTF-8
This tool focuses on the ASCII range (0–127) but also handles extended characters by showing their UTF-8 byte sequences.
Use Cases for ASCII-to-Hex Conversion
Serial communication: UART, RS-232, and SPI protocols transmit data as byte streams. When configuring or debugging serial devices, you often need to send specific ASCII characters by their hex codes — for example, 0x0D 0x0A for CRLF line endings or 0x1B for the escape character.
Terminal escape sequences: ANSI terminal control codes start with ESC (0x1B). Understanding the hex values helps when constructing colored output (\x1B[31m for red), cursor movement, and screen clearing commands.
Keyboard scan codes: When debugging keyboard input or building custom input handlers, you need to map key presses to their ASCII values. The relationship between uppercase and lowercase letters — A is 0x41, a is 0x61, differing by 0x20 — is a deliberate design feature of ASCII.
File format analysis: Many text-based file formats (CSV, JSON, XML, HTTP) use specific ASCII delimiters. Knowing that comma is 0x2C, colon is 0x3A, and the null terminator is 0x00 is essential for writing parsers and understanding binary boundaries.
Control characters in protocols: The ASCII control characters (0–31) have specific meanings in various protocols: 0x02 (STX, Start of Text) and 0x03 (ETX, End of Text) are framing characters in many industrial protocols; 0x06 (ACK) and 0x15 (NAK) are used for handshaking.
Notable ASCII Design Decisions
ASCII’s design contains elegant patterns that simplify programming:
- Digits 0–9 occupy
0x30–0x39. To convert a digit character to its numeric value, subtract0x30. To convert a number 0–9 to its ASCII character, add0x30. - Uppercase A–Z occupy
0x41–0x5A. Lowercase a–z occupy0x61–0x7A. The difference is exactly0x20(bit 5). Flipping bit 5 toggles case — this is why case-insensitive comparison can be done with a single OR operation. - Control characters (0–31) correspond to letters: Ctrl+A is
0x01, Ctrl+Z is0x1A. This isletter_code - 0x40.
Privacy
All conversion runs in your browser. No data is transmitted to any server.