A CSV export shows Café instead of Café. A protocol spec says a message ends with 0x0D 0x0A. A config file behaves oddly because it contains a tab where spaces were expected, and a hex dump of a file is full of numbers you need to translate back into letters. In each case, knowing the ASCII table turns a puzzle into something you can read.
This guide explains what ASCII is, how its 128 codes are laid out, what the control characters mean, why "extended ASCII" causes confusion, and how ASCII relates to Unicode and UTF-8, the encoding almost everything uses today.
A 7-bit alphabet for computers
ASCII (American Standard Code for Information Interchange) was standardised in the 1960s to give computers and teleprinters a shared way to represent text. It assigns a number from 0 to 127 to each character, which fits in 7 bits. Every modern encoding you are likely to meet keeps those same 128 assignments, which is why ASCII still matters.
The table has a deliberate structure:
| Range (decimal) | Hex | Contents |
|---|---|---|
| 0-31 | 00-1F | Control characters |
| 32 | 20 | Space |
| 33-47 | 21-2F | Punctuation and symbols |
| 48-57 | 30-39 | Digits 0-9 |
| 58-64 | 3A-40 | More punctuation, including : ; < = > ? @ |
| 65-90 | 41-5A | Uppercase A-Z |
| 91-96 | 5B-60 | [ \ ] ^ _ and the backtick |
| 97-122 | 61-7A | Lowercase a-z |
| 123-126 | 7B-7E | { ` |
| 127 | 7F | DEL (a control character) |
Some useful patterns fall out of this design:
- Digits are
0x30plus their value, so the character "7" is0x37. Subtracting 48 converts a digit character to its number. - Upper and lower case differ by exactly 32 (one bit,
0x20). "A" is 65 and "a" is 97. Flipping that bit changes case, which is why old code sometimes did case conversion with a bitwise operation. - Letters sort in order, so comparing codes gives alphabetical order for plain English text.
The control characters
Codes 0-31 and 127 do not print anything. They were designed to control devices: move the print head, ring a bell, mark the end of a transmission. Most are obsolete, but a handful are everywhere:
| Dec | Hex | Name | Escape | What it does today |
|---|---|---|---|---|
| 0 | 00 | NUL | \0 |
String terminator in C; often a sign of binary data |
| 9 | 09 | HT (tab) | \t |
Tab character |
| 10 | 0A | LF (line feed) | \n |
Line ending on Linux and macOS |
| 13 | 0D | CR (carriage return) | \r |
With LF, the Windows line ending (CRLF) |
| 27 | 1B | ESC | \x1b |
Starts terminal colour and cursor sequences |
| 127 | 7F | DEL | Originally "delete"; rarely used as data |
The CR/LF pair is a legacy of typewriters: return the carriage to the start of the line, then feed the paper up one line. HTTP headers, email and CSV files (per RFC 4180) still use CRLF, while Unix tools expect LF. Mixed line endings are a classic source of "the last column has an invisible character" bugs.
Converting between characters and codes
Each code can be written in several bases: decimal (65), hexadecimal (0x41), octal (101) and binary (01000001). In JavaScript:
console.log("A".charCodeAt(0)); // 65
console.log(String.fromCharCode(97)); // "a"
console.log((65).toString(16)); // "41"
console.log((65).toString(2).padStart(8, "0")); // "01000001"
// ASCII characters are one byte in UTF-8; others take more
console.log(new TextEncoder().encode("A")); // Uint8Array(1) [ 65 ]
console.log(new TextEncoder().encode("é")); // Uint8Array(2) [ 195, 169 ]
console.log(new TextEncoder().encode("€")); // Uint8Array(3) [ 226, 130, 172 ]
In HTML, any character can be written as a numeric entity: A or A for "A". For whole strings, the text to binary converter and the number base converter do the arithmetic for you.
Look up codes in the ASCII table
The ASCII Table lists every code with all its representations and copies any value with one click.
- Open the ASCII Table. Choose a range with the tabs: ASCII 0–127, Printable, Control or Extended 128–255.
- Search in the box: type a character, a decimal number, a hex value such as
0x1B, or a name liketaborcopy. - Read the columns: Char, Dec, Hex, Oct, Binary, HTML and Description. Control characters show their abbreviation and meaning.
- Click any value to copy it to the clipboard.
- In the Extended 128–255 tab, codes 128-159 also show the Windows-1252 character that occupies that slot.
"Extended ASCII" is not one thing
ASCII stops at 127. The eighth bit of a byte left room for 128 more characters, and many vendors filled it differently. IBM PCs used code page 437 with box-drawing characters. Western European systems used ISO-8859-1 (Latin-1). Windows used Windows-1252, which matches Latin-1 except for codes 128-159, where it places characters such as €, curly quotes ‘ ’ “ ” and the dash —. Other code pages served Greek, Cyrillic, Hebrew and more.
So "extended ASCII code 233" means é in Latin-1 and Windows-1252, but a different character in code page 437. Whenever someone says "extended ASCII", ask which code page.
ASCII, Unicode and UTF-8
Unicode assigns a unique number (a code point) to every character in every writing system, plus symbols and emoji. Its first 128 code points are identical to ASCII, and the first 256 match ISO-8859-1.
UTF-8 is the dominant way to store Unicode as bytes. It uses one byte for ASCII characters and two to four bytes for everything else. That design means every valid ASCII file is also a valid UTF-8 file, which is a big reason UTF-8 won.
Why you see Café
This is mojibake: text encoded as UTF-8 and decoded as Latin-1 or Windows-1252. The two bytes of é (0xC3 0xA9) are shown as two separate characters, à and ©. A right single quote ’ becomes ’. The fix is to read the file with the correct encoding, not to search and replace the symptoms. When opening CSV files in a spreadsheet, choose UTF-8 in the import dialog.
Tips and pitfalls
- Invisible characters. Tabs, non-breaking spaces (U+00A0, not ASCII at all) and zero-width characters look like spaces or nothing. Search by code to find them.
- Keyboard codes are different. JavaScript's legacy
keyCodefor a letter happens to equal its uppercase ASCII code, but key codes describe keys, not characters. The keycode finder shows those values. - HTML needs escaping for some ASCII characters.
<,>,&and quotes must become entities in HTML; the HTML entity encoder does this, and the guide on string escaping explains why.
Frequently asked questions
How many characters are in ASCII?
128, numbered 0 to 127. Of those, 95 are printable (including space) and 33 are control characters.
What is the ASCII code for a space?
32 in decimal, 0x20 in hexadecimal and 00100000 in binary.
Is ASCII the same as UTF-8?
No, but they overlap. The first 128 characters of UTF-8 are encoded exactly like ASCII, so ASCII text is valid UTF-8. UTF-8 then goes on to cover every Unicode character.
What is the difference between LF and CRLF?
LF (10) alone ends lines on Linux and macOS. Windows text files traditionally use CR (13) followed by LF. Many editors can convert between them.
Why is uppercase A 65 and lowercase a 97?
The designers placed the two alphabets exactly 32 apart, so case differs by a single bit. That made case conversion and case-insensitive comparison cheap on early hardware.