What Is ASCII? The Character Encoding That Underpins Modern Computing

ASCII (American Standard Code for Information Interchange) is a character encoding that assigns a number to each English letter, digit, punctuation mark, and a handful of control signals. Defined in 1963, it remains the foundation that nearly every modern text format and encoding is built on top of.

What ASCII actually is

A computer stores only numbers. To store text, it needs an agreed-upon table that says "the value 65 means the capital letter A." ASCII is exactly that table. It defines 128 characters, numbered 0 through 127, covering the uppercase and lowercase English alphabet, the digits 0 through 9, common punctuation, the space character, and 33 non-printing control characters used for things like line breaks and tabs.

Because the highest value is 127, every ASCII character fits in 7 bits (2 to the power of 7 equals 128). On modern hardware that uses 8-bit bytes, each ASCII character occupies one byte with the top bit set to zero. This 7-bits-in-an-8-bit-byte arrangement is why ASCII text is so compact and so easy to process.

How the encoding maps characters to numbers

The ASCII table is laid out deliberately, not arbitrarily, and the structure is genuinely useful to know.

  • 0 to 31 and 127 are control characters. Examples include code 9 (horizontal tab), code 10 (line feed, \n), code 13 (carriage return, \r), and code 0 (the null character).
  • 32 is the space.
  • 48 to 57 are the digits 0 through 9. Subtracting 48 from a digit's code gives its numeric value.
  • 65 to 90 are uppercase A through Z.
  • 97 to 122 are lowercase a through z.

A clever consequence: uppercase and lowercase letters differ by exactly 32. The bit with value 32 is the only difference between A (65) and a (97). Flipping that single bit converts case, which is why case-changing operations are historically so cheap.

Seeing it in practice

The word "Hi" followed by a newline encodes to these decimal values:

H  => 72
i  => 105
\n => 10

You can explore the full mapping interactively with the ASCII Table, and convert real text to and from its codes using the Hex to ASCII Converter or the Binary to Text Converter.

Why ASCII still matters

ASCII is over six decades old, yet it is more relevant than ever because of one decision made in the 1990s: UTF-8 was designed to be backward-compatible with ASCII. The first 128 code points of Unicode are identical to ASCII, and in UTF-8 those characters are encoded as the exact same single bytes. That means any valid ASCII file is automatically a valid UTF-8 file.

This compatibility is why ASCII underpins so much infrastructure. Source code keywords, HTTP headers, JSON syntax, email headers, DNS hostnames, and most configuration formats stick to the ASCII range deliberately, so they parse identically across systems regardless of locale or platform.

ASCII, extended ASCII, and Unicode

ASCII has no accented letters, no currency symbols beyond the dollar sign, and no non-Latin scripts. Because a byte can hold 256 values but ASCII only defines 128, vendors filled the upper half (128 to 255) with their own characters. These "extended ASCII" sets, such as Windows-1252 and the ISO 8859 family, are not a single standard and disagree with each other, which is a frequent source of garbled text.

Unicode solved this by defining a single, universal set of code points for every writing system, with UTF-8 as its dominant byte encoding. The right mental model today: ASCII is the small, universally-agreed core (0 to 127), and Unicode is the superset that extends far beyond it. When people say "plain ASCII text," they usually mean text that uses only those original 128 characters. To inspect characters above the ASCII range, the Unicode Inspector shows the underlying code points.

Where ASCII shows up in real work

You encounter ASCII constantly, even when the term is not used:

  • Programming languages compare characters by their ASCII values, which is why sorting puts Z (90) before a (97) in a naive byte sort.
  • Binary-to-text encodings like Base64 exist to carry arbitrary data through systems that only safely handle a subset of ASCII. See the Base64 Encoder/Decoder and the explainer on how Base64 encoding works.
  • URLs are restricted to a limited ASCII subset, so other characters must be percent-encoded with the URL Encoder/Decoder.
  • Protocols and wire formats use ASCII control characters and delimiters that have been stable for decades.

Common pitfalls

Most ASCII-related bugs come from confusing it with a full encoding or mishandling bytes outside its range.

The line-ending split

Windows ends lines with carriage return plus line feed (codes 13 and 10), while Unix and macOS use a lone line feed (code 10). Mixing them causes stray \r characters, broken diffs, and shell scripts that fail with cryptic errors.

Mojibake from wrong assumptions

Reading a UTF-8 file as Windows-1252 (or vice versa) turns multi-byte characters into garbage like é instead of é. The cause is almost always assuming an extended-ASCII code page when the data is really UTF-8. Always declare and honor the encoding explicitly.

Invisible and look-alike characters

Non-ASCII look-alikes (such as a Unicode minus sign that resembles a hyphen, or smart quotes pasted from a word processor) compile or parse incorrectly even though they look identical on screen. When a value mysteriously fails to match, checking for non-ASCII bytes is a fast first step.

Quick reference

PropertyASCII
Characters defined128 (values 0 to 127)
Bits per character7
Printable characters95 (codes 32 to 126)
Control characters33 (codes 0 to 31 and 127)
Relationship to UTF-8Identical for the first 128 code points

Understanding ASCII gives you a precise vocabulary for talking about text, encoding, and the bytes underneath. Once the 0-to-127 table is familiar, larger systems like Unicode and the many binary-to-text schemes become far easier to reason about.

Frequently Asked Questions

No. ASCII defines only 128 characters (0 to 127), while Unicode defines code points for virtually every writing system. However, the first 128 Unicode code points are identical to ASCII, so ASCII is effectively a subset of Unicode.

Standard ASCII uses 7 bits per character, which allows 128 distinct values. On modern systems each character is stored in one 8-bit byte with the highest bit set to zero.

Standard ASCII covers values 0 to 127 and is a single agreed-upon standard. Extended ASCII uses values 128 to 255, but there is no single definition for that range. Code pages like Windows-1252 and the ISO 8859 sets assign different characters to those values.

UTF-8, the dominant text encoding on the web, was designed so that ASCII text is also valid UTF-8 with identical bytes. Protocols, source code, and config formats stay within the ASCII range to guarantee consistent parsing across every platform.

They are 33 non-printing codes (0 to 31 and 127) that signal actions rather than display glyphs. Common examples are line feed (code 10), carriage return (code 13), horizontal tab (code 9), and null (code 0).