ASCII (American Standard Code for Information Interchange) is a character encoding standard that assigns numeric codes to letters, numbers, and symbols. This complete reference includes all 128 ASCII characters with decimal, hexadecimal, binary, and HTML entity values.
Quick Tip: Use Ctrl+F (Cmd+F on Mac) to quickly search for any character in the tables below.
Table of Contents
- What is ASCII?
- ASCII Control Characters (0-31)
- Printable ASCII Characters (32-126)
- Common ASCII Character Uses
- ASCII vs Unicode
- How to Use ASCII Codes
- Summary
What is ASCII?
ASCII is a 7-bit character encoding standard developed in the 1960s. Each character is represented by a number from 0 to 127, which computers use to store and transmit text. ASCII includes:
- Control characters (0-31): Non-printable codes used for text formatting and device control
- Printable characters (32-126): Letters, numbers, punctuation, and symbols you can see and type
- DEL character (127): Delete control character
Why ASCII Matters
ASCII forms the foundation of all modern character encoding systems. Even though UTF-8 and Unicode have largely replaced ASCII for international text, ASCII remains:
- The basis for URLs and domain names
- Essential for programming language syntax
- Used in network protocols and file formats
- The first 128 characters of UTF-8 and Unicode
Understanding ASCII helps you debug character encoding issues, work with legacy systems, and understand how computers represent text at a fundamental level.
ASCII Control Characters (0-31)
Control characters are non-printable codes used to control devices like printers and terminals. While many are obsolete, some remain essential.
Most Important Control Characters
| Dec | Hex | Binary | Char | Name | Common Use |
|---|---|---|---|---|---|
| 0 | 0x00 | 00000000 | NUL | Null | String terminator in C/C++ |
| 9 | 0x09 | 00001001 | HT | Tab | Horizontal tab, indentation |
| 10 | 0x0A | 00001010 | LF | Line Feed | New line (Unix/Linux/Mac) |
| 13 | 0x0D | 00001101 | CR | Carriage Return | New line in Windows (with LF) |
| 27 | 0x1B | 00011011 | ESC | Escape | Terminal escape sequences |
| 32 | 0x20 | 00100000 | SP | Space | Word separator |
View Tab character (9) | View Line Feed (10) | View Carriage Return (13)
Complete Control Characters Table
| Dec | Hex | Char | Name | Dec | Hex | Char | Name |
|---|---|---|---|---|---|---|---|
| 0 | 0x00 | NUL | Null | 16 | 0x10 | DLE | Data Link Escape |
| 1 | 0x01 | SOH | Start of Heading | 17 | 0x11 | DC1 | Device Control 1 |
| 2 | 0x02 | STX | Start of Text | 18 | 0x12 | DC2 | Device Control 2 |
| 3 | 0x03 | ETX | End of Text | 19 | 0x13 | DC3 | Device Control 3 |
| 4 | 0x04 | EOT | End of Transmission | 20 | 0x14 | DC4 | Device Control 4 |
| 5 | 0x05 | ENQ | Enquiry | 21 | 0x15 | NAK | Negative Acknowledge |
| 6 | 0x06 | ACK | Acknowledge | 22 | 0x16 | SYN | Synchronous Idle |
| 7 | 0x07 | BEL | Bell | 23 | 0x17 | ETB | End of Trans. Block |
| 8 | 0x08 | BS | Backspace | 24 | 0x18 | CAN | Cancel |
| 9 | 0x09 | HT | Horizontal Tab | 25 | 0x19 | EM | End of Medium |
| 10 | 0x0A | LF | Line Feed | 26 | 0x1A | SUB | Substitute |
| 11 | 0x0B | VT | Vertical Tab | 27 | 0x1B | ESC | Escape |
| 12 | 0x0C | FF | Form Feed | 28 | 0x1C | FS | File Separator |
| 13 | 0x0D | CR | Carriage Return | 29 | 0x1D | GS | Group Separator |
| 14 | 0x0E | SO | Shift Out | 30 | 0x1E | RS | Record Separator |
| 15 | 0x0F | SI | Shift In | 31 | 0x1F | US | Unit Separator |
Printable ASCII Characters (32-126)
These are the characters you can see and type on a standard keyboard.
Space and Symbols (32-47)
| Dec | Hex | Char | Description | Dec | Hex | Char | Description |
|---|---|---|---|---|---|---|---|
| 32 | 0x20 | | Space | 40 | 0x28 | ( | Left parenthesis |
| 33 | 0x21 | ! | Exclamation | 41 | 0x29 | ) | Right parenthesis |
| 34 | 0x22 | " | Double quote | 42 | 0x2A | * | Asterisk |
| 35 | 0x23 | # | Hash/Number | 43 | 0x2B | + | Plus |
| 36 | 0x24 | $ | Dollar | 44 | 0x2C | , | Comma |
| 37 | 0x25 | % | Percent | 45 | 0x2D | - | Hyphen/Minus |
| 38 | 0x26 | & | Ampersand | 46 | 0x2E | . | Period/Dot |
| 39 | 0x27 | ' | Single quote | 47 | 0x2F | / | Forward slash |
Numbers (48-57)
| Dec | Hex | Char | Dec | Hex | Char | Dec | Hex | Char |
|---|---|---|---|---|---|---|---|---|
| 48 | 0x30 | 0 | 51 | 0x33 | 3 | 54 | 0x36 | 6 |
| 49 | 0x31 | 1 | 52 | 0x34 | 4 | 55 | 0x37 | 7 |
| 50 | 0x32 | 2 | 53 | 0x35 | 5 | 56 | 0x38 | 8 |
More Symbols (58-64)
| Dec | Hex | Char | Description | Dec | Hex | Char | Description |
|---|---|---|---|---|---|---|---|
| 58 | 0x3A | : | Colon | 62 | 0x3E | > | Greater than |
| 59 | 0x3B | ; | Semicolon | 63 | 0x3F | ? | Question mark |
| 60 | 0x3C | < | Less than | 64 | 0x40 | @ | At sign |
| 61 | 0x3D | = | Equals |
Uppercase Letters (65-90)
| Dec | Hex | Char | Dec | Hex | Char | Dec | Hex | Char | Dec | Hex | Char |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 65 | 0x41 | A | 72 | 0x48 | H | 79 | 0x4F | O | 86 | 0x56 | V |
| 66 | 0x42 | B | 73 | 0x49 | I | 80 | 0x50 | P | 87 | 0x57 | W |
| 67 | 0x43 | C | 74 | 0x4A | J | 81 | 0x51 | Q | 88 | 0x58 | X |
| 68 | 0x44 | D | 75 | 0x4B | K | 82 | 0x52 | R | 89 | 0x59 | Y |
| 69 | 0x45 | E | 76 | 0x4C | L | 83 | 0x53 | S | 90 | 0x5A | Z |
| 70 | 0x46 | F | 77 | 0x4D | M | 84 | 0x54 | T | |||
| 71 | 0x47 | G | 78 | 0x4E | N | 85 | 0x55 | U |
Case Conversion Trick: Uppercase and lowercase letters are exactly 32 apart in ASCII. To convert uppercase to lowercase, add 32. To convert lowercase to uppercase, subtract 32.
Example: 'A' (65) + 32 = 'a' (97)
View letter A (65) | View all uppercase letters
Brackets and More (91-96)
| Dec | Hex | Char | Description | Dec | Hex | Char | Description |
|---|---|---|---|---|---|---|---|
| 91 | 0x5B | [ | Left bracket | 94 | 0x5E | ^ | Caret |
| 92 | 0x5C | \ | Backslash | 95 | 0x5F | _ | Underscore |
| 93 | 0x5D | ] | Right bracket | 96 | 0x60 | ` | Grave accent |
Lowercase Letters (97-122)
| Dec | Hex | Char | Dec | Hex | Char | Dec | Hex | Char | Dec | Hex | Char |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 97 | 0x61 | a | 104 | 0x68 | h | 111 | 0x6F | o | 118 | 0x76 | v |
| 98 | 0x62 | b | 105 | 0x69 | i | 112 | 0x70 | p | 119 | 0x77 | w |
| 99 | 0x63 | c | 106 | 0x6A | j | 113 | 0x71 | q | 120 | 0x78 | x |
| 100 | 0x64 | d | 107 | 0x6B | k | 114 | 0x72 | r | 121 | 0x79 | y |
| 101 | 0x65 | e | 108 | 0x6C | l | 115 | 0x73 | s | 122 | 0x7A | z |
| 102 | 0x66 | f | 109 | 0x6D | m | 116 | 0x74 | t | |||
| 103 | 0x67 | g | 110 | 0x6E | n | 117 | 0x75 | u |
View letter a (97) | View all lowercase letters
Final Characters (123-127)
| Dec | Hex | Char | Description |
|---|---|---|---|
| 123 | 0x7B | { | Left brace |
| 124 | 0x7C | | | Vertical bar |
| 125 | 0x7D | } | Right brace |
| 126 | 0x7E | ~ | Tilde |
| 127 | 0x7F | DEL | Delete |
Common ASCII Character Uses
Programming Characters
Essential Symbols:
- Space (32) - Most common character, separates tokens
- Tab (9) - Code indentation
- Parentheses ( ) (40, 41) - Function calls, grouping
- Brackets [ ] (91, 93) - Arrays, indexing
- Braces
{ }(123, 125) - Code blocks, objects - Semicolon ; (59) - Statement terminator
- Equals = (61) - Assignment operator
- Quotes " ' (34, 39) - Strings
Mathematical Operators:
- Plus + (43) - Addition
- Minus - (45) - Subtraction
- Asterisk * (42) - Multiplication
- Slash / (47) - Division
- Percent % (37) - Modulo
Comparison:
- Less than
<(60) - Greater than
>(62) - Equals = (61)
ASCII vs Unicode
| feature | ascii | unicode |
|---|---|---|
| Total Characters | 128 | 143,000+ |
| Encoding | 7-bit (fixed) | Variable (UTF-8, UTF-16, UTF-32) |
| Language Support | English only | All world languages |
| Emojis | No | Yes |
| File Size | Smaller (1 byte/char) | Larger (1-4 bytes/char) |
| Compatibility | Universal support | First 128 match ASCII |
| Development Year | 1963 | 1991 |
When to Use ASCII
โ Use ASCII for:
- Working with legacy systems
- File formats that require ASCII
- Network protocols
- Performance-critical applications
- Programming language keywords
When to Use Unicode
โ Use Unicode for:
- International websites
- Supporting multiple languages
- Emojis and special symbols
- Modern web development (UTF-8 is standard)
How to Use ASCII Codes
JavaScript
// Convert character to ASCII code
'A'.charCodeAt(0); // Returns: 65
'z'.charCodeAt(0); // Returns: 122
// Convert ASCII code to character
String.fromCharCode(65); // Returns: 'A'
String.fromCharCode(122); // Returns: 'z'
// Check if character is uppercase
function isUpperCase(char) {
const code = char.charCodeAt(0);
return code >= 65 && code <= 90;
}
// Check if character is a digit
function isDigit(char) {
const code = char.charCodeAt(0);
return code >= 48 && code <= 57;
}
// Convert case (using ASCII math)
function toUpperCase(char) {
const code = char.charCodeAt(0);
if (code >= 97 && code <= 122) {
return String.fromCharCode(code - 32);
}
return char;
}
function toLowerCase(char) {
const code = char.charCodeAt(0);
if (code >= 65 && code <= 90) {
return String.fromCharCode(code + 32);
}
return char;
}
Python
# Convert character to ASCII code
ord('A') # Returns: 65
ord('z') # Returns: 122
# Convert ASCII code to character
chr(65) # Returns: 'A'
chr(122) # Returns: 'z'
# Check if character is alphanumeric
def is_alphanumeric(char):
code = ord(char)
return (65 <= code <= 90) or (97 <= code <= 122) or (48 <= code <= 57)
# Case conversion
def to_upper(char):
code = ord(char)
if 97 <= code <= 122:
return chr(code - 32)
return char
C/C++
#include <stdio.h>
// Characters are already ASCII values
char c = 'A';
printf("%d", c); // Prints: 65
// Convert ASCII to character
char c = 65;
printf("%c", c); // Prints: A
// Check if uppercase
int isUpperCase(char c) {
return c >= 65 && c <= 90;
}
// Convert to lowercase
char toLowerCase(char c) {
if (c >= 65 && c <= 90) {
return c + 32;
}
return c;
}
Java
// Convert character to ASCII
char c = 'A';
int ascii = (int) c; // Returns: 65
// Convert ASCII to character
char c = (char) 65; // Returns: 'A'
// Using Character class
Character.isDigit('5'); // true
Character.isLetter('A'); // true
Character.isUpperCase('A'); // true
Character.toLowerCase('A'); // 'a'
PHP
<?php
// Convert character to ASCII
ord('A'); // Returns: 65
// Convert ASCII to character
chr(65); // Returns: 'A'
// Check character type
ctype_alpha('A'); // true
ctype_digit('5'); // true
ctype_upper('A'); // true
?>
Programming Patterns with ASCII
Caesar Cipher Example
function caesarCipher(text, shift) {
let result = '';
for (let i = 0; i < text.length; i++) {
let code = text.charCodeAt(i);
// Uppercase letters (65-90)
if (code >= 65 && code <= 90) {
code = ((code - 65 + shift) % 26) + 65;
}
// Lowercase letters (97-122)
else if (code >= 97 && code <= 122) {
code = ((code - 97 + shift) % 26) + 97;
}
result += String.fromCharCode(code);
}
return result;
}
caesarCipher('Hello World', 3);
// Returns: 'Khoor Zruog'
caesarCipher('Khoor Zruog', -3);
// Returns: 'Hello World'
Validating ASCII-Only Strings
// Check if string contains only ASCII characters
function isASCII(str) {
for (let i = 0; i < str.length; i++) {
if (str.charCodeAt(i) > 127) {
return false;
}
}
return true;
}
isASCII('Hello'); // true
isASCII('Hello ๐'); // false
// Remove non-ASCII characters
function removeNonASCII(str) {
return str.replace(/[^\x00-\x7F]/g, '');
}
removeNonASCII('Hello ๐ World');
// Returns: 'Hello World'
Quick Reference: Most Used ASCII Codes
| Character | Decimal | Hex | Common Use |
|---|---|---|---|
| Space | 32 | 0x20 | Word separator |
| 0-9 | 48-57 | 0x30-0x39 | Digits |
| A-Z | 65-90 | 0x41-0x5A | Uppercase letters |
| a-z | 97-122 | 0x61-0x7A | Lowercase letters |
| ! | 33 | 0x21 | Negation, emphasis |
| " | 34 | 0x22 | String delimiter |
| # | 35 | 0x23 | Hash, comments |
| $ | 36 | 0x24 | Variables, currency |
| % | 37 | 0x25 | Modulo operator |
| & | 38 | 0x26 | AND operator |
| ( ) | 40-41 | 0x28-0x29 | Function calls |
| * | 42 | 0x2A | Multiplication |
| + | 43 | 0x2B | Addition |
| , | 44 | 0x2C | Separator |
| - | 45 | 0x2D | Subtraction |
| . | 46 | 0x2E | Decimal, property access |
| / | 47 | 0x2F | Division, paths |
| : | 58 | 0x3A | Key-value separator |
| ; | 59 | 0x3B | Statement terminator |
< | 60 | 0x3C | Less than |
| = | 61 | 0x3D | Assignment |
> | 62 | 0x3E | Greater than |
| ? | 63 | 0x3F | Ternary operator |
| @ | 64 | 0x40 | Decorators, email |
| [ ] | 91,93 | 0x5B,0x5D | Arrays |
| \ | 92 | 0x5C | Escape character |
{ } | 123,125 | 0x7B,0x7D | Code blocks |
| | | 124 | 0x7C | OR operator, pipes |
Summary
ASCII remains fundamental to computing despite being 60+ years old. The first 128 characters of modern Unicode are identical to ASCII, ensuring backward compatibility. Whether you're debugging character encoding issues, working with legacy systems, or understanding how computers represent text, this ASCII table is your complete reference.
Key Takeaways:
โ
ASCII uses 7 bits to encode 128 characters (0-127)
โ
Control characters (0-31) handle formatting and device control
โ
Printable characters (32-126) include all letters, numbers, and symbols
โ
Uppercase and lowercase letters are exactly 32 apart
โ
Modern UTF-8 includes ASCII as its first 128 characters
โ
ASCII is still essential for programming, URLs, and protocols