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 (0–127) to each letter, digit, punctuation mark, and control character used in English text.
For example, the uppercase letter A is represented by the number 65, the digit 0 by 48, and a space by 32. This mapping allows computers to store and transmit text as a sequence of numbers.
ASCII uses 7 bits per character, giving it a total of 128 possible values (0–127). This covers the English alphabet (uppercase and lowercase), digits 0–9, common punctuation, and a set of control characters.
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 (ANSI X3.4-1986).
Before ASCII, different computer manufacturers used their own incompatible character codes — IBM used EBCDIC, while telegraph systems used Baudot code. ASCII provided a universal standard that allowed different systems to exchange text reliably.
ASCII was heavily influenced by telegraph codes and was designed to work with the teletype machines of the era. Many of its control characters (like carriage return and line feed) originate from these mechanical devices.
How ASCII Works
ASCII maps each character to a 7-bit binary number. Since most computers work with 8-bit bytes, the 8th bit is typically set to 0 (or used for error checking in older systems).
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 01101001Notice some useful patterns in the table:
- Uppercase letters (A–Z) are codes 65–90
- Lowercase letters (a–z) are codes 97–122
- The difference between upper and lowercase is always 32 (just one bit flip)
- Digits (0–9) are codes 48–57 — so the digit's value is always code − 48
The ASCII Table
Here are the key printable characters in ASCII (codes 32–126):
| 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 (0–31) are control characters— they don't represent printable symbols but rather instructions for devices. A few important ones you still encounter today:
| 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 (colors, cursor) |
| 127 | Delete | DEL | Originally used to "erase" punched tape characters |
The line ending difference between operating systems — \n (LF) on Unix vs \r\n (CR+LF) on Windows — is a direct legacy of ASCII control characters from the teletype era.
Printable Characters (32–126)
The 95 printable ASCII characters are organized into logical groups:
| Range | Codes | Description |
|---|---|---|
| Space | 32 | The space character |
| Punctuation/Symbols | 33–47, 58–64, 91–96, 123–126 | ! " # $ % & ' ( ) * + , - . / : ; etc. |
| 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
Working with ASCII codes is straightforward in most programming languages:
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 — enough for English, but not for the rest of the world. Unicode was created to solve this:
| Feature | ASCII | Unicode (UTF-8) |
|---|---|---|
| Characters | 128 | 149,000+ |
| Languages | English only | All modern scripts |
| Bits per char | 7 (stored as 8) | 8–32 (variable) |
| Emoji support | No | Yes |
| Backward compatible | — | Yes (first 128 chars are identical to ASCII) |
The key insight: UTF-8 is a superset of ASCII. Any valid ASCII text is also valid UTF-8. The first 128 Unicode code points are identical to ASCII, which is why ASCII remains relevant even in a Unicode world.
Where ASCII is Still Used Today
Despite being over 60 years old, ASCII is far from obsolete:
- Programming languages — Variable names, keywords, and syntax are all ASCII characters
- Network protocols — HTTP headers, SMTP commands, and FTP are ASCII-based protocols
- File formats — CSV, JSON, HTML, XML, and INI files use ASCII as their base
- URLs — Domain names and URL paths are restricted to ASCII (non-ASCII characters must be percent-encoded)
- Terminal/command line — Shell commands, file paths, and environment variables use ASCII
- Embedded systems — Resource-constrained devices often use ASCII for simplicity
- ASCII art — Creating visual art and diagrams from text characters remains popular in documentation and retro computing
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, which corresponds to a single bit flip in binary.
What is extended ASCII?
Extended ASCII uses the full 8-bit byte (codes 128–255) to add extra characters like accented letters, box-drawing symbols, and currency signs. However, there's no single "extended ASCII" — different systems (Latin-1, Windows-1252, etc.) used codes 128–255 differently, which is why Unicode was created.
Why are there control characters?
Control characters were designed for hardware — teletype machines, printers, and modems. Characters like BEL (7) would ring a physical bell, and CR (13) would return the print head to the start of the line. Many are obsolete now, but a few like LF, CR, TAB, and ESC are still used daily.
Can ASCII represent emojis or non-English characters?
No. ASCII only covers 128 characters — basic English letters, digits, and symbols. For emojis, Chinese, Arabic, or any non-English text, you need Unicode (typically 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 with no data uploaded to any server.
Try ASCII Converter →References
- 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