← All calculatorsTech

ASCII Calculator

ASCII maps 128 characters onto the numbers 0–127. Converting between character, decimal, hex and binary is routine debugging work — and knowing the layout of the table explains several familiar programming tricks.

Decimal
72 101 108 108 111
Hex
48 65 6c 6c 6f
Binary
1001000 1100101 1101100 1101100 1101111

How to use the ASCII Calculator

  1. Enter text to see each character's codes, or enter a code to get the character.
  2. Read decimal, hexadecimal and binary side by side.
  3. Use the control-character notes when inspecting whitespace or line endings.
  4. Switch to UTF-8 byte view for any character above 127.

How the calculation works

The table's structure is deliberate. Codes 0–31 are control characters (tab 9, line feed 10, carriage return 13), 32 is space, digits '0'–'9' occupy 48–57, uppercase 'A'–'Z' occupy 65–90 and lowercase 'a'–'z' occupy 97–122. Because upper and lower case sit exactly 32 apart — a single bit — case conversion is historically a bit flip, and subtracting 48 from a digit character gives its numeric value.

ASCII only covers 128 code points, so modern text is UTF-8, which is byte-compatible with ASCII for the first 128 values and uses two to four bytes above that. This is why an accented character can occupy one code point but two bytes, breaking length checks written for ASCII. Line-ending bugs come from the same table: LF alone on Unix, CR LF on Windows.

Formula
Digit value = code − 48 ; uppercase = lowercase − 32 ; hex = decimal in base 16

Source: ANSI X3.4 / ISO 646 ASCII character set and the UTF-8 encoding in RFC 3629.

Worked example

Encoding the string 'Hi9'.

  1. 'H' = 72 decimal = 0x48 = 01001000.
  2. 'i' = 105 decimal = 0x69 = 01101001.
  3. '9' = 57 decimal = 0x39 = 00111001.
  4. Numeric value of '9' = 57 − 48 = 9.

72 105 57 in decimal, or 48 69 39 in hex — three bytes, since all are within ASCII.

Frequently asked questions

What is the difference between ASCII and Unicode?+

ASCII defines 128 characters; Unicode defines over 140,000. UTF-8 encodes Unicode and matches ASCII for the first 128.

Why is uppercase 32 less than lowercase?+

The table was laid out so case differs by a single bit, making conversion a cheap bitwise operation.

What are control characters?+

Codes 0–31, originally teletype commands. Tab, line feed and carriage return are the ones still in daily use.

Why does my string length look wrong?+

You are probably counting bytes, not characters. Non-ASCII characters take multiple bytes in UTF-8.

Last reviewed August 31, 2026. We review this page whenever the underlying formula, tax year, published rate or standard changes.

Related

More in Tech