Skip to content

What Is ASCII? The Character Encoding Explained

Sep 11, 2026 · Formats & Standards

ASCII (the American Standard Code for Information Interchange) is a 7-bit character encoding that maps 128 code points, numbered 0 to 127, to control codes and the basic English letters, digits, punctuation, and space. Because it is 7-bit, ASCII fits within a single byte with a bit to spare, and it became the foundational text encoding from which many later standards, including UTF-8, were built. Understanding ASCII clarifies why text interchange works the way it does and why certain byte values behave specially.

Key takeaways

  • ASCII is a 7-bit code with exactly 128 code points (0 to 127).
  • Codes 0 to 31 and 127 are control characters; codes 32 to 126 are printable, including the space at 32.
  • Uppercase and lowercase letters are 32 apart, so A is 65 and a is 97.
  • UTF-8 is backward compatible with ASCII: the first 128 characters encode to identical single bytes.
  • Extended ASCII is a loose term for incompatible 8-bit encodings and is not part of the ASCII standard.

What is the structure of the ASCII table?

ASCII divides its 128 code points into two broad regions: non-printing control characters and printable characters.

Range Category Examples
0 to 31 Control characters Null (0), tab (9), line feed (10), carriage return (13)
32 Space The blank character
33 to 47 Punctuation and symbols ! " # & /
48 to 57 Digits 0 through 9
65 to 90 Uppercase letters A through Z
97 to 122 Lowercase letters a through z
127 Control character Delete

The remaining gaps hold additional punctuation. Everything a plain English document needs, including digits and both letter cases, fits in this compact 128-slot table.

What are ASCII control characters?

The first 32 codes plus code 127 are control characters. They were designed to control teleprinters and terminals rather than to display glyphs, and several remain essential today.

  • Null (0) is often used as a string terminator in low-level languages.
  • Tab (9) advances to the next tab stop.
  • Line feed (10) moves down a line; carriage return (13) returns to the start of the line.
  • Escape (27) introduces terminal escape sequences.

Line endings are a frequent source of cross-platform bugs: some systems mark a new line with a single line feed, while others use a carriage return followed by a line feed. Tools that assume one convention can mangle files produced with the other.

Why are uppercase and lowercase letters 32 apart?

The letter A is code 65 and a is code 97, a difference of exactly 32. This is not a coincidence: 32 is a single bit (the sixth bit) in the 7-bit value. As a result, converting a letter between cases is, at the bit level, just flipping that one bit. This tidy relationship is why simple case-conversion logic on ASCII letters is so efficient, though it applies only to the unaccented English letters, not to characters outside ASCII.

How does ASCII relate to UTF-8 and Unicode?

Unicode assigns a code point to essentially every character in every writing system, and its first 128 code points are deliberately identical to ASCII. UTF-8, the dominant Unicode encoding, was then designed so that those first 128 code points encode as a single byte with the same value as ASCII.

The consequence is powerful: any file that contains only ASCII characters is simultaneously valid UTF-8, byte for byte. This backward compatibility is a major reason UTF-8 succeeded, because existing ASCII text and tooling kept working unchanged while non-ASCII characters became expressible through multi-byte sequences.

Character  ASCII code  UTF-8 bytes
A          65          41
0          48          30
space       32          20

In each case the UTF-8 byte equals the ASCII code, shown here in hexadecimal.

What is extended ASCII and why is the term misleading?

Because a byte has eight bits but ASCII uses only seven, the values 128 to 255 were left unassigned by the standard. Many vendors filled that upper half with additional characters, producing a variety of 8-bit encodings loosely called extended ASCII. The problem is that these upper-half assignments were never standardized as one thing: different code pages placed different characters in the same byte values.

So a byte of 200 could mean entirely different characters depending on which code page a system assumed, which caused the classic garbled-text problem when files moved between systems. Because of this ambiguity, extended ASCII is best avoided as a precise term, and modern software should use Unicode encodings such as UTF-8 instead of relying on any 8-bit code page.

How is ASCII used in programming today?

ASCII remains central even though Unicode is now the norm:

  • Programming language keywords, identifiers in many languages, and most source code are ASCII.
  • Network protocols and text formats frequently define their syntax in terms of ASCII bytes.
  • Character classification, such as checking whether a byte is a digit or a letter, often relies on ASCII ranges.

A common performance pattern is to fast-path ASCII: since ASCII bytes are always less than 128 and never appear as continuation bytes in UTF-8, code can handle the ASCII case with simple range checks and fall back to full Unicode handling only when a byte’s high bit is set.

What mistakes do developers make with ASCII?

  1. Assuming all text is ASCII. Real-world input contains names, symbols, and emoji outside ASCII; assume UTF-8 instead.
  2. Confusing bytes with characters. In UTF-8 a non-ASCII character spans multiple bytes, so byte length is not character count.
  3. Relying on a specific extended-ASCII code page. The upper half is ambiguous; use Unicode.
  4. Mishandling line endings. Normalize carriage return and line feed conventions when reading cross-platform files.
  5. Applying the 32-bit case trick to non-ASCII letters. It only works for the basic English alphabet.

Frequently asked questions

How many characters does ASCII define?

ASCII defines 128 code points, numbered 0 through 127, because it is a 7-bit encoding. That includes 33 control characters and 95 printable characters.

Is ASCII a subset of UTF-8?

Yes. UTF-8 was designed so that the 128 ASCII characters encode to the exact same single bytes, which makes ASCII text automatically valid UTF-8.

What is the difference between control and printable characters?

Control characters (0 to 31 and 127) trigger actions like newline or tab and are not visible glyphs, while printable characters (32 to 126) represent visible symbols and the space.

What is extended ASCII?

It is an informal term for various 8-bit encodings that add 128 more characters above 127. These are not standard ASCII and differ between code pages, so the term is ambiguous.

What are the ASCII codes for A and a?

Uppercase A is 65 and lowercase a is 97. The two differ by 32, which is why toggling one bit converts between cases for the letters.

Why does ASCII only use 7 bits?

ASCII was standardized when 7 bits was sufficient for English text and control codes, leaving the eighth bit of a byte for parity or other uses at the time.

Is the newline character part of ASCII?

Yes. Line feed is code 10 and carriage return is code 13. Different systems use them singly or together to mark line endings.

Frequently asked questions

How many characters does ASCII define?

ASCII defines 128 code points, numbered 0 through 127, because it is a 7-bit encoding. That includes 33 control characters and 95 printable characters.

Is ASCII a subset of UTF-8?

Yes. UTF-8 was designed so that the 128 ASCII characters encode to the exact same single bytes, which makes ASCII text automatically valid UTF-8.

What is the difference between control and printable characters?

Control characters (0 to 31 and 127) trigger actions like newline or tab and are not visible glyphs, while printable characters (32 to 126) represent visible symbols and the space.

What is extended ASCII?

It is an informal term for various 8-bit encodings that add 128 more characters above 127. These are not standard ASCII and differ between code pages, so the term is ambiguous.

What are the ASCII codes for A and a?

Uppercase A is 65 and lowercase a is 97. The two differ by 32, which is why toggling one bit converts between cases for the letters.

Why does ASCII only use 7 bits?

ASCII was standardized when 7 bits was sufficient for English text and control codes, leaving the eighth bit of a byte for parity or other uses at the time.

Is the newline character part of ASCII?

Yes. Line feed is code 10 and carriage return is code 13. Different systems use them singly or together to mark line endings.

Contact: contact@quikconsolecom.net