The ASCII Table Explained: 0–127 Characters, Control Codes, and Printable Glyphs
Understand the ASCII table from character 0 to 127: control codes, printable glyphs, and decimal, hex and binary values, with practical programming uses.
The ASCII Table Explained: 0–127 Characters, Control Codes, and Printable Glyphs
Every time you type a letter into a code editor, that letter becomes a number before it becomes pixels. The mapping from letters to numbers is the ASCII table, and for English text it has stayed almost unchanged for sixty years. If you have ever wondered why 'A' equals 65, why a newline shows up as \n, or why 'a' - 'A' always equals 32, the ASCII table is where those answers live.
What ASCII Actually Is
ASCII stands for the American Standard Code for Information Interchange. It is a 7-bit character encoding, which means it assigns a number from 0 to 127 to each of its 128 characters. Seven bits gives you exactly 2^7 = 128 slots, and ASCII fills every one of them.
The standard was first published by the American Standards Association in 1963, then revised and locked into its modern form as ANSI X3.4 in 1967 (later renumbered, and today maintained as the basis of the Unicode C0 range). That 1967 layout is the one you still use: the same byte values for A, for space, for the digits 0–9. When people say UTF-8 is "ASCII-compatible," they mean the first 128 code points of Unicode are byte-for-byte identical to this table. A file that contains only ASCII characters is a valid UTF-8 file with zero changes.
I keep a printed ASCII chart taped next to my monitor, and the one thing I tell every junior engineer is this: ASCII is not text, it is a lookup table. Once you internalize that a character is just an index, half of string manipulation stops being magic.
The Two Halves: Control Characters and Printable Glyphs
The 128 codes split into two clearly different groups.
Codes 0–31 plus 127 are control characters. These do not draw anything on screen. They were designed to control teleprinters and terminals: move the carriage, ring a bell, signal the end of a transmission. The familiar ones survive in modern code:
0— NUL, the null terminator that ends C strings9— HT, the horizontal tab (\t)10— LF, line feed / newline (\n)13— CR, carriage return (\r)27— ESC, the escape that starts terminal color codes127— DEL, originally a "punch all holes" delete on paper tape
The CR/LF pair is why Windows text files use \r\n for a line break while Unix uses a bare \n — a difference that still trips up git diffs and shell scripts today.
Codes 32–126 are the printable characters. These are everything you can see: the space (32), punctuation, digits, and both cases of the Latin alphabet.
Decimal, Hexadecimal, and Binary Side by Side
The same character has one identity but several written forms. Looking at them together is the fastest way to build intuition. Here is the letter A and a few neighbors:
+------+---------+------+----------+
| Char | Decimal | Hex | Binary |
+------+---------+------+----------+
| ' ' | 32 | 0x20 | 0100000 |
| '0' | 48 | 0x30 | 0110000 |
| 'A' | 65 | 0x41 | 1000001 |
| 'a' | 97 | 0x61 | 1100001 |
| '~' | 126 | 0x7E | 1111110 |
+------+---------+------+----------+
A few patterns jump out once it is laid out this way. The digits 0–9 start at decimal 48 (0x30), so char - '0' converts a digit character to its integer value. Uppercase A is 65 and lowercase a is 97, exactly 32 apart, which is a single bit: 32 is 0b0100000. That is why flipping bit 5 toggles letter case, and why the cheap trick c | 0x20 lowercases an ASCII letter while c & ~0x20 uppercases it.
If you want to generate aligned reference tables like the one above — pasting in your own rows of characters and values — the ASCII Table Generator turns CSV or TSV straight into a monospace +--+ grid that drops cleanly into a README or a code comment.
Why Programmers Reach for the ASCII Table
Knowing these numbers is not trivia; it shows up in real work constantly.
Sorting and comparison. String comparison is just numeric comparison of code points. Because uppercase letters (65–90) come before lowercase (97–122), a naive sort puts Zebra before apple. Understanding that ordering explains a thousand "why is my sort wrong" bug reports.
Validation and parsing. Checking whether a byte is a digit is c >= '0' && c <= '9'. Checking for a printable character is c >= 32 && c <= 126. Whitespace stripping keys off codes 9, 10, 13, and 32. These ranges are the backbone of every hand-rolled tokenizer.
Encoding schemes. Base64, URL encoding, and escape sequences all assume an ASCII baseline. When you see %20 in a URL, that is hex 20 — the space character — encoded so it survives transport.
Terminal control. ANSI escape codes that color your terminal output begin with ESC (27) followed by [. Every colored log line you have ever seen starts with that control character.
A Worked Example
Suppose you read the byte 0x41 from a file and want to know what it is. Convert: 0x41 is 65 in decimal. Look up 65 in the table — it is A. Now read 0x61, which is 97 decimal, which is a. Subtract: 0x61 - 0x41 = 0x20 = 32. That confirms the case offset directly from raw bytes, no character logic required.
Here is the same idea as a short table you might paste into documentation:
+--------+------+-----+
| Byte | Char | Dec |
+--------+------+-----+
| 0x48 | H | 72 |
| 0x69 | i | 105 |
| 0x21 | ! | 33 |
+--------+------+-----+
Spell out the decimal column — 72, 105, 33 — and you have decoded Hi! from its byte values by hand.
Beyond Plain ASCII Tables
Once your reference table needs columns of prose, ASCII borders are still the most portable choice because they use only keyboard characters that render in any terminal or email client. When you are targeting a GitHub README that renders Markdown, a pipe table is cleaner, and the Markdown Table Generator produces that format from the same kind of CSV input. Pick ASCII borders for raw text and code comments, and Markdown for anything a renderer will see.
The takeaway is simple: ASCII is a fixed, 60-year-old lookup table of 128 entries, half control codes and half printable glyphs, and almost every low-level text operation you write rests on the arithmetic between those numbers.
Made by Toolora · Updated 2026-06-13