ASCII assigns a number from 0 to 127 to 128 characters: 33 control characters (0 to 31, and 127) and 95 printable characters (32 to 126, including the space). Every code fits in 7 bits. The two tables below list all 128 codes in decimal, hexadecimal, octal and 7-bit binary.
The data is not copied from another chart. The control character abbreviations and names follow the legend of RFC 20 (1969), which reproduces the USAS X3.4-1968 standard. The names of the printable characters are the official names from the Unicode Character Database 18.0. Unicode’s first 128 code points, U+0000 to U+007F, are the same characters as ASCII, so the code of a character in this table is also its Unicode code point.
ASCII table: printable characters 32–126
Codes 32 to 126 are the characters you can type on a US keyboard. 32 is the space, 48 to 57 are the digits, 65 to 90 the capital letters and 97 to 122 the small letters. The rest are punctuation and symbols.
| Dec | Hex | Oct | Binary | Char | Unicode name |
|---|---|---|---|---|---|
| 32 | 20 | 040 | 0100000 | (space) | SPACE |
| 33 | 21 | 041 | 0100001 | ! | EXCLAMATION MARK |
| 34 | 22 | 042 | 0100010 | " | QUOTATION MARK |
| 35 | 23 | 043 | 0100011 | # | NUMBER SIGN |
| 36 | 24 | 044 | 0100100 | $ | DOLLAR SIGN |
| 37 | 25 | 045 | 0100101 | % | PERCENT SIGN |
| 38 | 26 | 046 | 0100110 | & | AMPERSAND |
| 39 | 27 | 047 | 0100111 | ' | APOSTROPHE |
| 40 | 28 | 050 | 0101000 | ( | LEFT PARENTHESIS |
| 41 | 29 | 051 | 0101001 | ) | RIGHT PARENTHESIS |
| 42 | 2A | 052 | 0101010 | * | ASTERISK |
| 43 | 2B | 053 | 0101011 | + | PLUS SIGN |
| 44 | 2C | 054 | 0101100 | , | COMMA |
| 45 | 2D | 055 | 0101101 | - | HYPHEN-MINUS |
| 46 | 2E | 056 | 0101110 | . | FULL STOP |
| 47 | 2F | 057 | 0101111 | / | SOLIDUS |
| 48 | 30 | 060 | 0110000 | 0 | DIGIT ZERO |
| 49 | 31 | 061 | 0110001 | 1 | DIGIT ONE |
| 50 | 32 | 062 | 0110010 | 2 | DIGIT TWO |
| 51 | 33 | 063 | 0110011 | 3 | DIGIT THREE |
| 52 | 34 | 064 | 0110100 | 4 | DIGIT FOUR |
| 53 | 35 | 065 | 0110101 | 5 | DIGIT FIVE |
| 54 | 36 | 066 | 0110110 | 6 | DIGIT SIX |
| 55 | 37 | 067 | 0110111 | 7 | DIGIT SEVEN |
| 56 | 38 | 070 | 0111000 | 8 | DIGIT EIGHT |
| 57 | 39 | 071 | 0111001 | 9 | DIGIT NINE |
| 58 | 3A | 072 | 0111010 | : | COLON |
| 59 | 3B | 073 | 0111011 | ; | SEMICOLON |
| 60 | 3C | 074 | 0111100 | < | LESS-THAN SIGN |
| 61 | 3D | 075 | 0111101 | = | EQUALS SIGN |
| 62 | 3E | 076 | 0111110 | > | GREATER-THAN SIGN |
| 63 | 3F | 077 | 0111111 | ? | QUESTION MARK |
| 64 | 40 | 100 | 1000000 | @ | COMMERCIAL AT |
| 65 | 41 | 101 | 1000001 | A | LATIN CAPITAL LETTER A |
| 66 | 42 | 102 | 1000010 | B | LATIN CAPITAL LETTER B |
| 67 | 43 | 103 | 1000011 | C | LATIN CAPITAL LETTER C |
| 68 | 44 | 104 | 1000100 | D | LATIN CAPITAL LETTER D |
| 69 | 45 | 105 | 1000101 | E | LATIN CAPITAL LETTER E |
| 70 | 46 | 106 | 1000110 | F | LATIN CAPITAL LETTER F |
| 71 | 47 | 107 | 1000111 | G | LATIN CAPITAL LETTER G |
| 72 | 48 | 110 | 1001000 | H | LATIN CAPITAL LETTER H |
| 73 | 49 | 111 | 1001001 | I | LATIN CAPITAL LETTER I |
| 74 | 4A | 112 | 1001010 | J | LATIN CAPITAL LETTER J |
| 75 | 4B | 113 | 1001011 | K | LATIN CAPITAL LETTER K |
| 76 | 4C | 114 | 1001100 | L | LATIN CAPITAL LETTER L |
| 77 | 4D | 115 | 1001101 | M | LATIN CAPITAL LETTER M |
| 78 | 4E | 116 | 1001110 | N | LATIN CAPITAL LETTER N |
| 79 | 4F | 117 | 1001111 | O | LATIN CAPITAL LETTER O |
| 80 | 50 | 120 | 1010000 | P | LATIN CAPITAL LETTER P |
| 81 | 51 | 121 | 1010001 | Q | LATIN CAPITAL LETTER Q |
| 82 | 52 | 122 | 1010010 | R | LATIN CAPITAL LETTER R |
| 83 | 53 | 123 | 1010011 | S | LATIN CAPITAL LETTER S |
| 84 | 54 | 124 | 1010100 | T | LATIN CAPITAL LETTER T |
| 85 | 55 | 125 | 1010101 | U | LATIN CAPITAL LETTER U |
| 86 | 56 | 126 | 1010110 | V | LATIN CAPITAL LETTER V |
| 87 | 57 | 127 | 1010111 | W | LATIN CAPITAL LETTER W |
| 88 | 58 | 130 | 1011000 | X | LATIN CAPITAL LETTER X |
| 89 | 59 | 131 | 1011001 | Y | LATIN CAPITAL LETTER Y |
| 90 | 5A | 132 | 1011010 | Z | LATIN CAPITAL LETTER Z |
| 91 | 5B | 133 | 1011011 | [ | LEFT SQUARE BRACKET |
| 92 | 5C | 134 | 1011100 | \ | REVERSE SOLIDUS |
| 93 | 5D | 135 | 1011101 | ] | RIGHT SQUARE BRACKET |
| 94 | 5E | 136 | 1011110 | ^ | CIRCUMFLEX ACCENT |
| 95 | 5F | 137 | 1011111 | _ | LOW LINE |
| 96 | 60 | 140 | 1100000 | ` | GRAVE ACCENT |
| 97 | 61 | 141 | 1100001 | a | LATIN SMALL LETTER A |
| 98 | 62 | 142 | 1100010 | b | LATIN SMALL LETTER B |
| 99 | 63 | 143 | 1100011 | c | LATIN SMALL LETTER C |
| 100 | 64 | 144 | 1100100 | d | LATIN SMALL LETTER D |
| 101 | 65 | 145 | 1100101 | e | LATIN SMALL LETTER E |
| 102 | 66 | 146 | 1100110 | f | LATIN SMALL LETTER F |
| 103 | 67 | 147 | 1100111 | g | LATIN SMALL LETTER G |
| 104 | 68 | 150 | 1101000 | h | LATIN SMALL LETTER H |
| 105 | 69 | 151 | 1101001 | i | LATIN SMALL LETTER I |
| 106 | 6A | 152 | 1101010 | j | LATIN SMALL LETTER J |
| 107 | 6B | 153 | 1101011 | k | LATIN SMALL LETTER K |
| 108 | 6C | 154 | 1101100 | l | LATIN SMALL LETTER L |
| 109 | 6D | 155 | 1101101 | m | LATIN SMALL LETTER M |
| 110 | 6E | 156 | 1101110 | n | LATIN SMALL LETTER N |
| 111 | 6F | 157 | 1101111 | o | LATIN SMALL LETTER O |
| 112 | 70 | 160 | 1110000 | p | LATIN SMALL LETTER P |
| 113 | 71 | 161 | 1110001 | q | LATIN SMALL LETTER Q |
| 114 | 72 | 162 | 1110010 | r | LATIN SMALL LETTER R |
| 115 | 73 | 163 | 1110011 | s | LATIN SMALL LETTER S |
| 116 | 74 | 164 | 1110100 | t | LATIN SMALL LETTER T |
| 117 | 75 | 165 | 1110101 | u | LATIN SMALL LETTER U |
| 118 | 76 | 166 | 1110110 | v | LATIN SMALL LETTER V |
| 119 | 77 | 167 | 1110111 | w | LATIN SMALL LETTER W |
| 120 | 78 | 170 | 1111000 | x | LATIN SMALL LETTER X |
| 121 | 79 | 171 | 1111001 | y | LATIN SMALL LETTER Y |
| 122 | 7A | 172 | 1111010 | z | LATIN SMALL LETTER Z |
| 123 | 7B | 173 | 1111011 | { | LEFT CURLY BRACKET |
| 124 | 7C | 174 | 1111100 | | | VERTICAL LINE |
| 125 | 7D | 175 | 1111101 | } | RIGHT CURLY BRACKET |
| 126 | 7E | 176 | 1111110 | ~ | TILDE |
ASCII control characters 0–31 and 127
The control characters were designed for teleprinters and data links, not for display. The Caret column shows how terminals write them: a control code is produced by holding Ctrl with the key whose code is 64 higher, so code 3 is ^C (Ctrl+C) and code 27 is ^[. The C escape column gives the escape sequences defined by the C language. Python accepts all of them in string literals, and JavaScript all except \a. C has no short escape for ESC; \x1b is a hexadecimal escape, and \0 is the octal escape for zero.
| Dec | Hex | Oct | Binary | Abbr | Name | Caret | C escape |
|---|---|---|---|---|---|---|---|
| 0 | 00 | 000 | 0000000 | NUL | Null | ^@ | \0 |
| 1 | 01 | 001 | 0000001 | SOH | Start of Heading | ^A | — |
| 2 | 02 | 002 | 0000010 | STX | Start of Text | ^B | — |
| 3 | 03 | 003 | 0000011 | ETX | End of Text | ^C | — |
| 4 | 04 | 004 | 0000100 | EOT | End of Transmission | ^D | — |
| 5 | 05 | 005 | 0000101 | ENQ | Enquiry | ^E | — |
| 6 | 06 | 006 | 0000110 | ACK | Acknowledge | ^F | — |
| 7 | 07 | 007 | 0000111 | BEL | Bell | ^G | \a |
| 8 | 08 | 010 | 0001000 | BS | Backspace | ^H | \b |
| 9 | 09 | 011 | 0001001 | HT | Horizontal Tabulation | ^I | \t |
| 10 | 0A | 012 | 0001010 | LF | Line Feed | ^J | \n |
| 11 | 0B | 013 | 0001011 | VT | Vertical Tabulation | ^K | \v |
| 12 | 0C | 014 | 0001100 | FF | Form Feed | ^L | \f |
| 13 | 0D | 015 | 0001101 | CR | Carriage Return | ^M | \r |
| 14 | 0E | 016 | 0001110 | SO | Shift Out | ^N | — |
| 15 | 0F | 017 | 0001111 | SI | Shift In | ^O | — |
| 16 | 10 | 020 | 0010000 | DLE | Data Link Escape | ^P | — |
| 17 | 11 | 021 | 0010001 | DC1 | Device Control 1 | ^Q | — |
| 18 | 12 | 022 | 0010010 | DC2 | Device Control 2 | ^R | — |
| 19 | 13 | 023 | 0010011 | DC3 | Device Control 3 | ^S | — |
| 20 | 14 | 024 | 0010100 | DC4 | Device Control 4 | ^T | — |
| 21 | 15 | 025 | 0010101 | NAK | Negative Acknowledge | ^U | — |
| 22 | 16 | 026 | 0010110 | SYN | Synchronous Idle | ^V | — |
| 23 | 17 | 027 | 0010111 | ETB | End of Transmission Block | ^W | — |
| 24 | 18 | 030 | 0011000 | CAN | Cancel | ^X | — |
| 25 | 19 | 031 | 0011001 | EM | End of Medium | ^Y | — |
| 26 | 1A | 032 | 0011010 | SUB | Substitute | ^Z | — |
| 27 | 1B | 033 | 0011011 | ESC | Escape | ^[ | \x1b |
| 28 | 1C | 034 | 0011100 | FS | File Separator | ^\ | — |
| 29 | 1D | 035 | 0011101 | GS | Group Separator | ^] | — |
| 30 | 1E | 036 | 0011110 | RS | Record Separator | ^^ | — |
| 31 | 1F | 037 | 0011111 | US | Unit Separator | ^_ | — |
| 127 | 7F | 177 | 1111111 | DEL | Delete | ^? | — |
RFC 20 notes that DEL is “not a control character” in the strict sense. Its code is all seven bits set (1111111), because on paper tape a character was erased by punching all of its holes.
Reading the table: what the bit patterns tell you
ASCII was laid out so that simple bit operations work. Split the 128 codes into four blocks of 32, using the two highest bits:
| Code range | Hex | Bits 6–5 | Contents |
|---|---|---|---|
| 0–31 | 00–1F | 00 | Control characters |
| 32–63 | 20–3F | 01 | Space, digits and most punctuation |
| 64–95 | 40–5F | 10 | @, capital letters, [ \ ] ^ _ |
| 96–127 | 60–7F | 11 | `, small letters, { | } ~, DEL |
Three useful rules follow from this layout:
- Capital and small letters differ by 32.
Ais 65 (1000001) andais 97 (1100001); only bit 5 (value 32, hex0x20) differs. Setting that bit makes a letter small, clearing it makes it capital. This only works for the 52 letters, so check the range first:[(91) with bit 5 set becomes{(123). - A digit’s value is its code minus 48.
'7'is 55, and 55 − 48 = 7. In hex the digits are0x30to0x39, so the low four bits are the digit itself. - Ctrl clears the two high bits. Ctrl+letter gives the letter’s code AND 31 (
0x1F):Cis 67, and 67 AND 31 = 3, which is ETX. This is why Ctrl+M (13) acts as Enter and Ctrl+I (9) as Tab in a terminal.
Control characters you still meet
Most of the 33 control codes are now unused, but a few appear every day:
- LF (10) and CR (13) end lines. Unix and macOS text files use LF alone; Windows text files use CR followed by LF. Internet protocols also use CR LF: HTTP/1.1 (RFC 9112) ends each header line with it, and so does SMTP (RFC 5321).
- HT (9) is the tab key. GNU make requires it at the start of every recipe line unless you change the prefix with
.RECIPEPREFIX. - NUL (0) ends a string in C. A NUL byte in the middle of text is often the first sign that a file is UTF-16, because ASCII characters in UTF-16 are followed or preceded by a zero byte.
- ESC (27) starts the terminal control sequences defined in ECMA-48.
ESC [ 3 1 mswitches the text color to red, andESC [ 0 mresets it, which is how colored log output works. - ETX (3), EOT (4), DC1 (17), DC3 (19), SUB (26) and DEL (127) are the Ctrl keys a Unix terminal reacts to. On macOS,
stty -alistsintr = ^C,eof = ^D,start = ^Q,stop = ^S,susp = ^Zanderase = ^?: Ctrl+C interrupts a program, Ctrl+D ends input, Ctrl+S and Ctrl+Q pause and resume output (the old XOFF/XON flow control), and the Backspace key sends DEL. - RS (30) separates records in JSON text sequences (RFC 7464), where each JSON text starts with an RS byte. The four separators FS, GS, RS and US were intended for structured data like this, from the largest unit (file) to the smallest (unit).
ASCII order and sorting
Because every capital letter has a lower code than every small letter, sorting strings by their codes puts all capitalized words first. JavaScript’s default sort() compares UTF-16 code units, which match ASCII codes for ASCII text:
['apple', 'Banana', '_id', '10', '9', 'Zebra'].sort();
// [ '10', '9', 'Banana', 'Zebra', '_id', 'apple' ]
'10' comes before '9' because the first characters are compared first, and 1 (49) is lower than 9 (57). _ (95) sorts between the capital letters (65–90) and the small letters (97–122). The Unix sort command gives the same order when you set LC_ALL=C; with a language locale it uses that locale’s collation rules instead, which is why the same file can sort differently on two machines.
Codes 128–255 are not ASCII
A byte has 8 bits, and ASCII only defines values up to 127. Values 128 to 255 depend on the encoding, which is why there is no single “extended ASCII” table. The same byte 0x80 decodes to three different results:
| Encoding | Byte 0x80 decodes to |
|---|---|
| Windows-1252 | € (U+20AC) |
| ISO-8859-1 | U+0080, an invisible C1 control character |
| Code page 437 (the original IBM PC) | Ç (U+00C7) |
Browsers add one more twist. The WHATWG Encoding Standard treats the labels iso-8859-1, latin1, us-ascii and ascii as names for Windows-1252, so a page declared as ISO-8859-1 shows 0x80 as €.
UTF-8 keeps ASCII intact. RFC 3629 states that ASCII characters are encoded in one byte with their normal value, and that a byte with such a value can only stand for an ASCII character. Every byte of a multi-byte UTF-8 sequence is 128 or higher. A file that contains only ASCII is therefore already valid UTF-8, and a program that looks for , or \n in UTF-8 data byte by byte cannot match part of another character.
Looking up codes with the ASCII Converter
The ASCII Converter converts in both directions in your browser. Type text in the left box and click Text → ASCII to get one code per character in the format you select:
Hex: 0x48 0x69 0x21
Binary: 0b1001000 0b1101001 0b100001
The binary output drops leading zeros, so ! (33) is 0b100001 with six digits, not the seven-digit 0100001 used in the tables above. Pad the result yourself if you need fixed-width bit strings.
ASCII → Text reads codes separated by spaces, commas or line breaks, and each code can use its own prefix: 0x48, 0o151 0b100001 decodes to Hi!. A code without a prefix is decimal. If a code is not entirely made of digits of its base, nothing is converted and the status line shows the problem, for example Error: Invalid code: 72abc.
Characters outside ASCII are shown as their Unicode code point, not as bytes. é gives 0xE9 (233), although in UTF-8 it is stored as the two bytes C3 A9. The tool also has a collapsible reference table of the printable characters 32 to 126.
Finding non-ASCII characters in text
A common job is to find the character that makes a file “not ASCII”: a curly apostrophe pasted from a word processor, a no-break space or a zero-width character. Converting the suspicious word shows it at once:
Don’t → 68 111 110 8217 116
8217 is U+2019 RIGHT SINGLE QUOTATION MARK, not the ASCII apostrophe (39). To check a whole string in code, test whether every code is below 128:
s = "Don’t panic"
s.isascii() # False
[(c, ord(c)) for c in s if ord(c) > 127] # [('’', 8217)]
/[^\x00-\x7F]/.test('Don’t panic'); // true
[...'Don’t panic'].filter((c) => c.codePointAt(0) > 127); // [ '’' ]
str.isascii() exists in Python 3.7 and later. For invisible characters, the Invisible Character Detector lists each hidden code point with its name.