ASCII, Binary and Hex: Converting Between Them

ASCII, Binary and Hex: Converting Between Them

A byte is a number between 0 and 255. Depending on who is asking, you write it as 65, 01000001, or 41 — and all three mean the same thing. The confusion is not the maths, it is remembering which notation the other person expects.

The ASCII / binary / hex converter shows all three at once, so you can paste any of them and read the rest.

What ASCII actually covers

ASCII defines 128 characters — 0 to 127 — as a 7-bit code. That includes control characters (0–31), printable punctuation and digits (32–64), uppercase letters (65–90), and lowercase letters (97–122).

The useful anchors, worth memorising:

Character Decimal Hex
A 65 41
Z 90 5A
a 97 61
z 122 7A
0 48 30
space 32 20

The gap between A and a is exactly 32 — one bit. That is why toUpperCase is a bit flip in the old days, and why ASCII was designed for case-insensitive terminals.

Why hex

Hex is a compact, aligned way to write bytes. One byte is exactly two hex digits — no guessing where a number ends. That is why memory dumps, colour codes, hashes and protocol specs are all in hex.

The trap: 0x31 is the character 1, not the number 31. Programs that read “31” as decimal and byte 0x31 as text produce famously confusing bugs.

Where binary is genuinely used

Binary is verbose but it shows bit-level structure. File permission masks (rwx), network masks, and flag registers are easier to reason about as 11110101 than as 0xF5.

For anything above a single byte, though, hex wins on readability.

UTF-8 changes the assumption

ASCII only covers English. UTF-8 encodes everything else as one to four bytes, and is backward-compatible: any ASCII text is valid UTF-8 with the same bytes.

That is why 你好 becomes e4 bd a0 e5 a5 bd — six bytes, two characters — and why a tool that silently assumes “one number = one character” produces garbage on non-English input.

Our converter treats input as UTF-8 bytes, so Chinese, emoji and accented text all work. A single code point above 255 (for example 20320, 你) is also accepted as a code point rather than a byte.

Converting in practice

  • Text → binary: useful for teaching, and for hand-encoding into constrained protocols.
  • Hex → text: read a byte dump, or debug a payload captured from the network.
  • Hex without spaces: 48656C6C6F is five bytes, not one huge number. The converter splits even-length runs into byte pairs automatically.