·8 min read

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.

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 01101001

Notice 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):

CodeCharCodeCharCodeChar
32Space48064@
33!49165A
34"50266B
35#51367C
36$52468D
37%53569E
38&54670F
39'55771G
40(56872H
41)57973I
42*58:74J
43+59;75K
44,60<76L
45-61=77M
46.62>78N
47/63?79O
80P96`112p
81Q97a113q
82R98b114r
83S99c115s
84T100d116t
85U101e117u
86V102f118v
87W103g119w
88X104h120x
89Y105i121y
90Z106j122z
91[107k123{
92\108l124|
93]109m125}
94^110n126~

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:

CodeNameAbbreviationUsage
0NullNULString terminator in C/C++
9Horizontal TabHTThe tab character (\t)
10Line FeedLFNew line on Unix/Linux/macOS (\n)
13Carriage ReturnCRUsed with LF on Windows (\r\n)
27EscapeESCTerminal escape sequences (colors, cursor)
127DeleteDELOriginally 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:

RangeCodesDescription
Space32The space character
Punctuation/Symbols33–47, 58–64, 91–96, 123–126! " # $ % & ' ( ) * + , - . / : ; etc.
Digits48–570 1 2 3 4 5 6 7 8 9
Uppercase Letters65–90A B C D E F ... Z
Lowercase Letters97–122a 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;  // 3

ASCII vs Unicode

ASCII only covers 128 characters — enough for English, but not for the rest of the world. Unicode was created to solve this:

FeatureASCIIUnicode (UTF-8)
Characters128149,000+
LanguagesEnglish onlyAll modern scripts
Bits per char7 (stored as 8)8–32 (variable)
Emoji supportNoYes
Backward compatibleYes (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

  1. ANSI. (1986). ANSI X3.4-1986 — Coded Character Sets — 7-Bit American National Standard Code for Information Interchange. https://www.ansi.org
  2. Cerf, V. (1969). ASCII format for Network Interchange. RFC 20, IETF. https://datatracker.ietf.org/doc/html/rfc20
  3. Mozilla Developer Network. String.prototype.charCodeAt() — JavaScript. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt
  4. The Unicode Consortium. The Unicode Standard. https://www.unicode.org/standard/standard.html
  5. Wikipedia. ASCII — History and Development. https://en.wikipedia.org/wiki/ASCII