What is ASCII? The Character Encoding That Started It All
Every letter, number, and symbol you type has a numeric code behind it. ASCII is where that story begins: the encoding standard that gave computers a common language for text.
Table of Contents
What is ASCII?
ASCII stands for American Standard Code for Information Interchange. It is a character encoding standard that assigns a unique numeric code from 0 to 127 to letters, digits, punctuation marks, and control characters used in English text.
For example, uppercase A is represented by 65, the digit 0 by 48, and a space by 32. This mapping lets computers store and transmit text as a sequence of numbers.
ASCII uses 7 bits per character, giving it 128 possible values. That is enough for the English alphabet in uppercase and lowercase, digits 0-9, common punctuation, and a small set of control commands.
A Brief History of ASCII
ASCII was developed in the early 1960s by a committee of the American Standards Association, now ANSI. It was first published as a standard in 1963 and last updated in 1986 as ANSI X3.4-1986.
Before ASCII, computer and communication systems often used incompatible character codes. IBM systems used EBCDIC, telegraph systems used Baudot code, and exchanging text between machines was harder than it should have been.
ASCII created a shared text vocabulary for computers, terminals, printers, and networks. Many of its control characters, such as carriage return and line feed, come directly from teletype machines and other mechanical devices of that era.
How ASCII Works
ASCII maps each character to a 7-bit binary number. Modern computers usually store those values in 8-bit bytes, with the extra bit set to 0 or used historically for parity checking.
Character -> Decimal -> Binary
'A' -> 65 -> 01000001
'B' -> 66 -> 01000010
'a' -> 97 -> 01100001
'0' -> 48 -> 00110000
' ' -> 32 -> 00100000
'!' -> 33 -> 00100001
The word "Hi" is stored as:
H = 72, i = 105
Binary: 01001000 01101001A few patterns make ASCII easy to recognize and use:
- Uppercase letters A-Z use codes 65-90.
- Lowercase letters a-z use codes 97-122.
- The difference between uppercase and lowercase is always 32, which is one useful bit difference.
- Digits 0-9 use codes 48-57, so a digit's numeric value is its code minus 48.
The ASCII Table
Here are the key printable ASCII characters. The first printable value is 32, the space character, and the last is 126, the tilde.
| Code | Char | Code | Char | Code | Char |
|---|---|---|---|---|---|
| 32 | Space | 48 | 0 | 64 | @ |
| 33 | ! | 49 | 1 | 65 | A |
| 34 | " | 50 | 2 | 66 | B |
| 35 | # | 51 | 3 | 67 | C |
| 36 | $ | 52 | 4 | 68 | D |
| 37 | % | 53 | 5 | 69 | E |
| 38 | & | 54 | 6 | 70 | F |
| 39 | ' | 55 | 7 | 71 | G |
| 40 | ( | 56 | 8 | 72 | H |
| 41 | ) | 57 | 9 | 73 | I |
| 42 | * | 58 | : | 74 | J |
| 43 | + | 59 | ; | 75 | K |
| 44 | , | 60 | < | 76 | L |
| 45 | - | 61 | = | 77 | M |
| 46 | . | 62 | > | 78 | N |
| 47 | / | 63 | ? | 79 | O |
| 80 | P | 96 | ` | 112 | p |
| 81 | Q | 97 | a | 113 | q |
| 82 | R | 98 | b | 114 | r |
| 83 | S | 99 | c | 115 | s |
| 84 | T | 100 | d | 116 | t |
| 85 | U | 101 | e | 117 | u |
| 86 | V | 102 | f | 118 | v |
| 87 | W | 103 | g | 119 | w |
| 88 | X | 104 | h | 120 | x |
| 89 | Y | 105 | i | 121 | y |
| 90 | Z | 106 | j | 122 | z |
| 91 | [ | 107 | k | 123 | { |
| 92 | \ | 108 | l | 124 | | |
| 93 | ] | 109 | m | 125 | } |
| 94 | ^ | 110 | n | 126 | ~ |
Control Characters (0-31)
The first 32 ASCII codes are control characters. They do not represent printable symbols. Instead, they are instructions originally meant for terminals, printers, modems, and teletypes. A few still matter every day:
| Code | Name | Abbreviation | Usage |
|---|---|---|---|
| 0 | Null | NUL | String terminator in C/C++ |
| 9 | Horizontal Tab | HT | The tab character (\t) |
| 10 | Line Feed | LF | New line on Unix/Linux/macOS (\n) |
| 13 | Carriage Return | CR | Used with LF on Windows (\r\n) |
| 27 | Escape | ESC | Terminal escape sequences for colors and cursor movement |
| 127 | Delete | DEL | Originally used to erase punched tape characters |
The line ending difference between operating systems, \n on Unix-like systems and \r\n on Windows, is a direct legacy of ASCII control characters.
Printable Characters (32-126)
The 95 printable ASCII characters are organized into logical ranges:
| Range | Codes | Description |
|---|---|---|
| Space | 32 | The space character |
| Punctuation/Symbols | 33-47, 58-64, 91-96, 123-126 | ! " # $ % & ' ( ) * + , - . / : ; and more |
| Digits | 48-57 | 0 1 2 3 4 5 6 7 8 9 |
| Uppercase Letters | 65-90 | A B C D E F ... Z |
| Lowercase Letters | 97-122 | a b c d e f ... z |
ASCII in Code
Most programming languages make it easy to convert between characters and ASCII codes:
JavaScript
// Character to ASCII code
"A".charCodeAt(0); // 65
"a".charCodeAt(0); // 97
" ".charCodeAt(0); // 32
// ASCII code to character
String.fromCharCode(65); // "A"
String.fromCharCode(72, 101, 108, 108, 111); // "Hello"
// Convert case using ASCII math
const lower = String.fromCharCode("A".charCodeAt(0) + 32); // "a"
const upper = String.fromCharCode("a".charCodeAt(0) - 32); // "A"Python
# Character to ASCII code
ord('A') # 65
ord('a') # 97
# ASCII code to character
chr(65) # 'A'
chr(97) # 'a'
# Convert a string to ASCII codes
[ord(c) for c in "Hello"] # [72, 101, 108, 108, 111]Practical Tricks
// Check if a character is a digit
const isDigit = (c) => c.charCodeAt(0) >= 48 && c.charCodeAt(0) <= 57;
// Check if a character is a letter
const isLetter = (c) => {
const code = c.charCodeAt(0);
return (code >= 65 && code <= 90) || (code >= 97 && code <= 122);
};
// Get alphabet position (A=1, B=2, ...)
const position = "C".charCodeAt(0) - 64; // 3ASCII vs Unicode
ASCII only covers 128 characters, which is enough for basic English text but not for the rest of the world. Unicode was created to represent many scripts, symbols, and emojis:
| Feature | ASCII | Unicode (UTF-8) |
|---|---|---|
| Characters | 128 | 149,000+ |
| Languages | English only | All modern scripts |
| Bits per character | 7 (stored as 8) | 8-32, variable length |
| Emoji support | No | Yes |
| Backward compatibility | - | Yes, the first 128 code points match ASCII |
The key idea is that UTF-8 is a superset of ASCII. Any valid ASCII text is also valid UTF-8, which is why ASCII remains relevant even in a Unicode world.
Where ASCII is Still Used Today
Despite being more than 60 years old, ASCII is still everywhere:
- Programming languages - variable names, keywords, operators, and syntax are mostly ASCII characters.
- Network protocols - HTTP headers, SMTP commands, FTP, and many older protocols are ASCII-based.
- File formats - CSV, JSON, HTML, XML, Markdown, and INI files all build on ASCII-compatible text.
- URLs - domain names and many URL components are ASCII-first; other characters are encoded.
- Terminals and command lines - shell commands, environment variables, and many file paths rely on ASCII-compatible text.
- Embedded systems - small devices often use ASCII because it is simple, compact, and predictable.
- ASCII art - diagrams and text-based visuals are still common in documentation, logs, and retro computing culture.
Common Questions
Is ASCII case-sensitive?
Yes. Uppercase and lowercase letters have different codes. "A" is 65 and "a" is 97. The difference is always 32.
What is extended ASCII?
Extended ASCII usually means using the full 8-bit byte, codes 128-255, for extra symbols. There is no single universal extended ASCII, because Latin-1, Windows-1252, and other encodings use that range differently.
Why are there control characters?
They were designed for hardware such as teletypes, printers, and modems. BEL rang a bell, CR returned the print head, and LF advanced the paper. Some, like TAB, LF, CR, and ESC, are still used today.
Can ASCII represent emojis or non-English characters?
No. ASCII only covers 128 basic English-oriented characters. For Thai, Chinese, Arabic, emojis, and most modern text, you need Unicode, usually encoded as UTF-8.
Convert Text to ASCII Codes
Use our free ASCII Converter tool to convert text to ASCII codes or decode ASCII values back to text right in your browser.
Try ASCII ConverterReferences
- ANSI. (1986). ANSI X3.4-1986 - Coded Character Sets - 7-Bit American National Standard Code for Information Interchange. https://www.ansi.org
- Cerf, V. (1969). ASCII format for Network Interchange. RFC 20, IETF. https://datatracker.ietf.org/doc/html/rfc20
- Mozilla Developer Network. String.prototype.charCodeAt() - JavaScript. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt
- The Unicode Consortium. The Unicode Standard. https://www.unicode.org/standard/standard.html
- Wikipedia. ASCII - History and Development. https://en.wikipedia.org/wiki/ASCII