/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 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 01101001

A 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.

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

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 for colors and cursor movement
127DeleteDELOriginally 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:

RangeCodesDescription
Space32The space character
Punctuation/Symbols33-47, 58-64, 91-96, 123-126! " # $ % & ' ( ) * + , - . / : ; and more
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

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;  // 3

ASCII 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:

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