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.

DecHexOctBinaryCharUnicode name
32200400100000(space)SPACE
33210410100001!EXCLAMATION MARK
34220420100010"QUOTATION MARK
35230430100011#NUMBER SIGN
36240440100100$DOLLAR SIGN
37250450100101%PERCENT SIGN
38260460100110&AMPERSAND
39270470100111'APOSTROPHE
40280500101000(LEFT PARENTHESIS
41290510101001)RIGHT PARENTHESIS
422A0520101010*ASTERISK
432B0530101011+PLUS SIGN
442C0540101100,COMMA
452D0550101101-HYPHEN-MINUS
462E0560101110.FULL STOP
472F0570101111/SOLIDUS
483006001100000DIGIT ZERO
493106101100011DIGIT ONE
503206201100102DIGIT TWO
513306301100113DIGIT THREE
523406401101004DIGIT FOUR
533506501101015DIGIT FIVE
543606601101106DIGIT SIX
553706701101117DIGIT SEVEN
563807001110008DIGIT EIGHT
573907101110019DIGIT NINE
583A0720111010:COLON
593B0730111011;SEMICOLON
603C0740111100<LESS-THAN SIGN
613D0750111101=EQUALS SIGN
623E0760111110>GREATER-THAN SIGN
633F0770111111?QUESTION MARK
64401001000000@COMMERCIAL AT
65411011000001ALATIN CAPITAL LETTER A
66421021000010BLATIN CAPITAL LETTER B
67431031000011CLATIN CAPITAL LETTER C
68441041000100DLATIN CAPITAL LETTER D
69451051000101ELATIN CAPITAL LETTER E
70461061000110FLATIN CAPITAL LETTER F
71471071000111GLATIN CAPITAL LETTER G
72481101001000HLATIN CAPITAL LETTER H
73491111001001ILATIN CAPITAL LETTER I
744A1121001010JLATIN CAPITAL LETTER J
754B1131001011KLATIN CAPITAL LETTER K
764C1141001100LLATIN CAPITAL LETTER L
774D1151001101MLATIN CAPITAL LETTER M
784E1161001110NLATIN CAPITAL LETTER N
794F1171001111OLATIN CAPITAL LETTER O
80501201010000PLATIN CAPITAL LETTER P
81511211010001QLATIN CAPITAL LETTER Q
82521221010010RLATIN CAPITAL LETTER R
83531231010011SLATIN CAPITAL LETTER S
84541241010100TLATIN CAPITAL LETTER T
85551251010101ULATIN CAPITAL LETTER U
86561261010110VLATIN CAPITAL LETTER V
87571271010111WLATIN CAPITAL LETTER W
88581301011000XLATIN CAPITAL LETTER X
89591311011001YLATIN CAPITAL LETTER Y
905A1321011010ZLATIN CAPITAL LETTER Z
915B1331011011[LEFT SQUARE BRACKET
925C1341011100\REVERSE SOLIDUS
935D1351011101]RIGHT SQUARE BRACKET
945E1361011110^CIRCUMFLEX ACCENT
955F1371011111_LOW LINE
96601401100000`GRAVE ACCENT
97611411100001aLATIN SMALL LETTER A
98621421100010bLATIN SMALL LETTER B
99631431100011cLATIN SMALL LETTER C
100641441100100dLATIN SMALL LETTER D
101651451100101eLATIN SMALL LETTER E
102661461100110fLATIN SMALL LETTER F
103671471100111gLATIN SMALL LETTER G
104681501101000hLATIN SMALL LETTER H
105691511101001iLATIN SMALL LETTER I
1066A1521101010jLATIN SMALL LETTER J
1076B1531101011kLATIN SMALL LETTER K
1086C1541101100lLATIN SMALL LETTER L
1096D1551101101mLATIN SMALL LETTER M
1106E1561101110nLATIN SMALL LETTER N
1116F1571101111oLATIN SMALL LETTER O
112701601110000pLATIN SMALL LETTER P
113711611110001qLATIN SMALL LETTER Q
114721621110010rLATIN SMALL LETTER R
115731631110011sLATIN SMALL LETTER S
116741641110100tLATIN SMALL LETTER T
117751651110101uLATIN SMALL LETTER U
118761661110110vLATIN SMALL LETTER V
119771671110111wLATIN SMALL LETTER W
120781701111000xLATIN SMALL LETTER X
121791711111001yLATIN SMALL LETTER Y
1227A1721111010zLATIN SMALL LETTER Z
1237B1731111011{LEFT CURLY BRACKET
1247C1741111100|VERTICAL LINE
1257D1751111101}RIGHT CURLY BRACKET
1267E1761111110~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.

DecHexOctBinaryAbbrNameCaretC escape
0000000000000NULNull^@\0
1010010000001SOHStart of Heading^A—
2020020000010STXStart of Text^B—
3030030000011ETXEnd of Text^C—
4040040000100EOTEnd of Transmission^D—
5050050000101ENQEnquiry^E—
6060060000110ACKAcknowledge^F—
7070070000111BELBell^G\a
8080100001000BSBackspace^H\b
9090110001001HTHorizontal Tabulation^I\t
100A0120001010LFLine Feed^J\n
110B0130001011VTVertical Tabulation^K\v
120C0140001100FFForm Feed^L\f
130D0150001101CRCarriage Return^M\r
140E0160001110SOShift Out^N—
150F0170001111SIShift In^O—
16100200010000DLEData Link Escape^P—
17110210010001DC1Device Control 1^Q—
18120220010010DC2Device Control 2^R—
19130230010011DC3Device Control 3^S—
20140240010100DC4Device Control 4^T—
21150250010101NAKNegative Acknowledge^U—
22160260010110SYNSynchronous Idle^V—
23170270010111ETBEnd of Transmission Block^W—
24180300011000CANCancel^X—
25190310011001EMEnd of Medium^Y—
261A0320011010SUBSubstitute^Z—
271B0330011011ESCEscape^[\x1b
281C0340011100FSFile Separator^\—
291D0350011101GSGroup Separator^]—
301E0360011110RSRecord Separator^^—
311F0370011111USUnit Separator^_—
1277F1771111111DELDelete^?—

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 rangeHexBits 6–5Contents
0–3100–1F00Control characters
32–6320–3F01Space, digits and most punctuation
64–9540–5F10@, capital letters, [ \ ] ^ _
96–12760–7F11`, small letters, { | } ~, DEL

Three useful rules follow from this layout:

  • Capital and small letters differ by 32. A is 65 (1000001) and a is 97 (1100001); only bit 5 (value 32, hex 0x20) 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 are 0x30 to 0x39, 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): C is 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 m switches the text color to red, and ESC [ 0 m resets 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 -a lists intr = ^C, eof = ^D, start = ^Q, stop = ^S, susp = ^Z and erase = ^?: 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:

EncodingByte 0x80 decodes to
Windows-1252€ (U+20AC)
ISO-8859-1U+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.