ASCII (American Standard Code for Information Interchange) is a character encoding standard that maps 128 characters to numbers 0–127. It includes control characters (0–31, 127), digits (48–57), uppercase letters (65–90), lowercase letters (97–122), and punctuation/symbols. ASCII was published in 1963 and remains the foundation of all modern text encoding including UTF-8 and Unicode.
This interactive reference table lets you search, filter, and convert between characters and their decimal, hexadecimal, octal, and binary codes. Code examples in C, JavaScript, and Python are included below.
101 • C: 'A' • HTML: A| Dec | Hex | Oct | Binary | Char | Description | Category |
|---|
'A' (65) + 32 = 'a' (97). The difference between any uppercase letter and its lowercase counterpart is always 32.
'5' (53) − 48 = 5. Subtract 48 (or '0') from a digit character's ASCII value to get the actual number.
Standard ASCII uses only 7 bits (0–127). Extended ASCII (128–255) varies by system and is NOT standardized.
In binary, bit 5 (value 32) determines case. Set bit 5 → lowercase. Clear bit 5 → uppercase. A single XOR flips case!
#include <stdio.h>
int main() {
printf("Dec Hex Oct Char Description\n");
printf("--- --- --- ---- -----------\n");
for (int i = 32; i <= 126; i++) {
printf("%-4d %-4X %-4o %-5c Printable\n", i, i, i, i);
}
// Character to ASCII
char ch = 'A';
printf("\n'%c' = ASCII %d (Hex: %X)\n", ch, ch, ch);
// ASCII to character
int code = 97;
printf("ASCII %d = '%c'\n", code, code);
return 0;
}Dec Hex Oct Char Description --- --- --- ---- ----------- 32 20 40 ␣ Printable 33 21 41 ! Printable ... 65 41 101 A Printable ... 126 7E 176 ~ Printable 'A' = ASCII 65 (Hex: 41) ASCII 97 = 'a'
printf("%d", ch)— In C, a char IS its ASCII value. Printing with %d gives the number, %c gives the character.(int) i, (char) i— Casting between int and char converts between ASCII code and character seamlessly.for (32 to 126)— ASCII 32–126 are printable characters. 0–31 and 127 are control characters.// Character → ASCII code
console.log("'A' →", "A".charCodeAt(0)); // 65
console.log("'a' →", "a".charCodeAt(0)); // 97
console.log("'0' →", "0".charCodeAt(0)); // 48
console.log("'!' →", "!".charCodeAt(0)); // 33
// ASCII code → Character
console.log("65 →", String.fromCharCode(65)); // A
console.log("97 →", String.fromCharCode(97)); // a
console.log("48 →", String.fromCharCode(48)); // 0
// Print all printable ASCII characters
let table = "";
for (let i = 32; i <= 126; i++) {
table += String.fromCharCode(i) + " ";
if ((i - 31) % 16 === 0) table += "\n";
}
console.log("\nPrintable ASCII:\n" + table);
// Check if character is uppercase
const isUpper = (ch) => {
const code = ch.charCodeAt(0);
return code >= 65 && code <= 90;
};
console.log("\nIs 'H' uppercase?", isUpper("H")); // true
console.log("Is 'h' uppercase?", isUpper("h")); // false
// Convert lowercase to uppercase using ASCII
const toUpper = (ch) =>
String.fromCharCode(ch.charCodeAt(0) - 32);
console.log("'d' to upper:", toUpper("d")); // D'A' → 65 'a' → 97 '0' → 48 '!' → 33 65 → A 97 → a 48 → 0 Printable ASCII: ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O ... Is 'H' uppercase? true Is 'h' uppercase? false 'd' to upper: D
str.charCodeAt(0)— Returns the ASCII (Unicode) value of the character at position 0.String.fromCharCode(65)— Creates a character from its ASCII code — the reverse of charCodeAt.code >= 65 && code <= 90— ASCII 65–90 are uppercase A–Z. This range check identifies uppercase letters.charCodeAt(0) - 32— Lowercase - 32 = Uppercase (e.g., a=97, A=65, difference is 32). A classic ASCII trick!# Character → ASCII code
print("'A' →", ord('A')) # 65
print("'a' →", ord('a')) # 97
print("'0' →", ord('0')) # 48
# ASCII code → Character
print("65 →", chr(65)) # A
print("97 →", chr(97)) # a
# Print printable ASCII table
print("\nPrintable ASCII Characters:")
for i in range(32, 127):
print(f"{i:3d} {i:02X} {chr(i):>3}", end=" ")
if (i - 31) % 8 == 0:
print()
# Uppercase check
def is_upper(ch):
return 65 <= ord(ch) <= 90
print(f"\nIs 'H' upper? {is_upper('H')}")
# Caesar cipher (rotate by 3)
def caesar_encrypt(text, shift=3):
result = ""
for ch in text:
if ch.isalpha():
base = ord('A') if ch.isupper() else ord('a')
result += chr((ord(ch) - base + shift) % 26 + base)
else:
result += ch
return result
msg = "Hello India"
encrypted = caesar_encrypt(msg)
print(f"\nOriginal: {msg}")
print(f"Encrypted: {encrypted}")
print(f"Decrypted: {caesar_encrypt(encrypted, -3)}")'A' → 65 'a' → 97 '0' → 48 65 → A 97 → a Printable ASCII Characters: 32 20 33 21 ! 34 22 " 35 23 # ... Is 'H' upper? True Original: Hello India Encrypted: Khoor Lqgld Decrypted: Hello India
ord(ch)— Python's built-in function to get the ASCII value of a character.chr(code)— Converts an ASCII code number back to its character.Caesar cipher— A classic encryption technique that shifts each letter by a fixed number of positions using ASCII math.| Feature | ASCII | Unicode | UTF-8 |
|---|---|---|---|
| Characters | 128 | 149,000+ | 149,000+ |
| Bits Used | 7 bits | Up to 21 bits | 8–32 bits (variable) |
| Languages | English only | All languages + emoji | All languages + emoji |
| Hindi Support | ❌ No | ✅ Yes (Devanagari) | ✅ Yes |
| Backward Compatible | — | ⚠️ Depends on encoding | ✅ With ASCII |
| File Size | Smallest | Varies | Efficient for English |
| Year Introduced | 1963 | 1991 | 1993 |
char is just a small integer — it stores the ASCII value directly.\n, ASCII 9 (TAB) = \t, ASCII 0 (NUL) = \0 — essential for C strings.Write a C program to print all printable ASCII characters (32–126) with their decimal and hex values.
Convert a string from uppercase to lowercase using ASCII arithmetic (±32), without built-in functions.
Implement a Caesar cipher that shifts each letter by N positions using ASCII math and modulo.
Given a string like "abc123def", extract only digit characters using ASCII range checks (48–57).
Count vowels in a string using their ASCII values. Handle both uppercase and lowercase.
Convert a binary string (01000001) to its ASCII character and display it.
Your support helps us build more free programming tools and references for students across India. 🇮🇳
Buy me a Coffee ☕