ASCII Table

ASCII is a 7-bit character code with 128 values, 0 to 127: 33 control codes and 95 printable characters. The table gives each code in decimal, hex, octal and binary. Bytes 128 to 255 are not ASCII; they belong to code pages such as Windows-1252.

ASCII table: codes 0 to 127 in decimal, hex, octal and binary

Click any value to copy it
ASCII codes 0 to 127
DecHexOctBinaryCharName
00000000000000NULNUL Null
10100100000001SOHSOH Start of heading
20200200000010STXSTX Start of text
30300300000011ETXETX End of text
40400400000100EOTEOT End of transmission
50500500000101ENQENQ Enquiry
60600600000110ACKACK Acknowledge
70700700000111BELBEL Bell
80801000001000BSBS Backspace
90901100001001HTHT Horizontal tab
100A01200001010LFLF Line feed
110B01300001011VTVT Vertical tab
120C01400001100FFFF Form feed
130D01500001101CRCR Carriage return
140E01600001110SOSO Shift out
150F01700001111SISI Shift in
161002000010000DLEDLE Data link escape
171102100010001DC1DC1 Device control 1
181202200010010DC2DC2 Device control 2
191302300010011DC3DC3 Device control 3
201402400010100DC4DC4 Device control 4
211502500010101NAKNAK Negative acknowledge
221602600010110SYNSYN Synchronous idle
231702700010111ETBETB End of transmission block
241803000011000CANCAN Cancel
251903100011001EMEM End of medium
261A03200011010SUBSUB Substitute
271B03300011011ESCESC Escape
281C03400011100FSFS File separator
291D03500011101GSGS Group separator
301E03600011110RSRS Record separator
311F03700011111USUS Unit separator
322004000100000␠Space
332104100100001!
342204200100010"
352304300100011#
362404400100100$
372504500100101%
382604600100110&
392704700100111'
402805000101000(
412905100101001)
422A05200101010*
432B05300101011+
442C05400101100,
452D05500101101-
462E05600101110.
472F05700101111/
4830060001100000
4931061001100011
5032062001100102
5133063001100113
5234064001101004
5335065001101015
5436066001101106
5537067001101117
5638070001110008
5739071001110019
583A07200111010:
593B07300111011;
603C07400111100<
613D07500111101=
623E07600111110>
633F07700111111?
644010001000000@
654110101000001A
664210201000010B
674310301000011C
684410401000100D
694510501000101E
704610601000110F
714710701000111G
724811001001000H
734911101001001I
744A11201001010J
754B11301001011K
764C11401001100L
774D11501001101M
784E11601001110N
794F11701001111O
805012001010000P
815112101010001Q
825212201010010R
835312301010011S
845412401010100T
855512501010101U
865612601010110V
875712701010111W
885813001011000X
895913101011001Y
905A13201011010Z
915B13301011011[
925C13401011100\
935D13501011101]
945E13601011110^
955F13701011111_
966014001100000`
976114101100001a
986214201100010b
996314301100011c
1006414401100100d
1016514501100101e
1026614601100110f
1036714701100111g
1046815001101000h
1056915101101001i
1066A15201101010j
1076B15301101011k
1086C15401101100l
1096D15501101101m
1106E15601101110n
1116F15701101111o
1127016001110000p
1137116101110001q
1147216201110010r
1157316301110011s
1167416401110100t
1177516501110101u
1187616601110110v
1197716701110111w
1207817001111000x
1217917101111001y
1227A17201111010z
1237B17301111011{
1247C17401111100|
1257D17501111101}
1267E17601111110~
1277F17701111111DELDEL Delete

Control characters, codes 0 to 31 and 127

The first 32 codes and the last one do not print anything. They were defined for teleprinters and punched tape, and they steer the machine at the other end: start a new line, ring a bell, mark the end of a message. Most are obsolete, but about a dozen still do real work in terminals, text files and network protocols. The table gives the standard abbreviation, the name, and what the code is used for now.

The 33 ASCII control characters
DecHexAbbr.NameUse today
000NULNullString terminator in C; padding in binary data
101SOHStart of headingRare; framing in old serial protocols
202STXStart of textRare; framing in old serial protocols
303ETXEnd of textCtrl+C in terminals sends this byte (interrupt)
404EOTEnd of transmissionCtrl+D in Unix terminals signals end of input
505ENQEnquiryRare; handshake in old serial protocols
606ACKAcknowledgeRare; positive reply in serial protocols
707BELBellMakes the terminal beep
808BSBackspaceMoves the cursor back one position
909HTHorizontal tabThe Tab key; indents text
100ALFLine feedNewline on Unix, Linux and macOS
110BVTVertical tabRare; vertical spacing
120CFFForm feedPage break on printers
130DCRCarriage returnPart of the Windows line ending CR LF
140ESOShift outRare; switches character set
150FSIShift inRare; switches character set back
1610DLEData link escapeRare; escapes control codes in protocols
1711DC1Device control 1XON: resume transmission (Ctrl+Q)
1812DC2Device control 2Rare; device control
1913DC3Device control 3XOFF: pause transmission (Ctrl+S)
2014DC4Device control 4Rare; device control
2115NAKNegative acknowledgeRare; negative reply in serial protocols
2216SYNSynchronous idleRare; sync in old serial protocols
2317ETBEnd of transmission blockRare; block framing
2418CANCancelCancels the current line or message
2519EMEnd of mediumRare; end of tape or disk
261ASUBSubstituteMarks a bad character; Ctrl+Z is end of file in DOS and Windows
271BESCEscapeStarts terminal escape sequences; the Esc key
281CFSFile separatorSeparator in structured data streams
291DGSGroup separatorSeparator in structured data streams
301ERSRecord separatorSeparator in structured data streams (used by JSON Text Sequences)
311FUSUnit separatorSeparator in structured data streams
1277FDELDeleteErases the character; was used to punch out paper tape

Three of them decide how a text file ends its lines. Line feed (10, 0A) is the newline on Linux and macOS, carriage return (13, 0D) was the newline on classic Mac OS, and Windows uses both in a row, CR LF. A file with the wrong line ending shows as one long line or as a stray character at the end of every line, and that is the usual reason a script copied between systems fails. The tab (9, 09) and the NUL (0, 00) are the other two worth recognizing in a hex view: NUL ends a string in C, and a run of 00 bytes in a text file points to UTF-16 or to binary data.

On a keyboard, holding Ctrl and pressing a letter clears the top bits of the letter's code and sends the control code beneath it. Ctrl+C sends 03 (end of text), Ctrl+G sends 07 (the bell), Ctrl+I is the same as Tab (09), Ctrl+J is a line feed (0A), and Ctrl+[ is Escape (1B). That is why terminals show ^C and ^[ for those keys.

Printable characters, codes 32 to 126

The 95 printable codes start at the space (32, hex 20) and end at the tilde (126, hex 7E). They fall into four runs, and knowing where the runs begin lets you read most ASCII hex without a table: punctuation and symbols are scattered through 20 to 2F, 3A to 40, 5B to 60 and 7B to 7E; the digits sit at 30 to 39; capital letters at 41 to 5A; lower case at 61 to 7A.

The layout was chosen so that simple operations are bit operations. The digit characters carry their value in the low four bits, so "7" is 37 and subtracting 30 gives the number 7. Capital and lower case letters of the same letter are 32 apart, which is a single bit, the one worth 20 in hex.

Upper and lower case differ in bit 5A is 01000001, a is 01100001, Z is 01011010, z is 01111010. Only the bit worth 32 changes.bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0A 41h 6501000001a 61h 9701100001Z 5Ah 9001011010z 7Ah 12201111010
Bit 5 (worth 32, hex 20) is 0 for capital letters and 1 for lower case. Adding 32 to a capital letter gives the lower case letter.

The consequence is that a mask converts case: clearing bit 5 (AND with DF) makes a letter upper case, and setting it (OR with 20) makes it lower case. This only works for letters. Applied to a digit or to punctuation it changes the character, which is a common source of bugs in hand-written case conversion.

Extended ASCII: codes 128 to 255 are not ASCII

ASCII has 128 codes because it is a 7-bit code. A byte has eight bits, and the spare bit was used for parity on serial lines, or, once memory was cheaper, to add 128 more characters. Each vendor added different ones, so there is no such thing as one extended ASCII. The name covers many code pages, and a byte above 7F means different things depending on which one the sender used.

Two code pages matter on the web. ISO 8859-1, called Latin-1, maps byte 0 to FF onto the first 256 Unicode code points, so E9 is U+00E9, é. Windows-1252 is the Microsoft variation: identical to Latin-1 except in 80 to 9F, where Latin-1 has C1 control codes that almost nobody uses and Windows-1252 has useful printable characters, including the euro sign, curly quotation marks, the en and em dashes and the trademark sign. Five bytes (81, 8D, 8F, 90 and 9D) are not assigned in Windows-1252 at all. Browsers treat a page labelled ISO-8859-1 as Windows-1252, as the WHATWG Encoding Standard requires, so text that mixes the two usually displays as the Windows version.

Bytes 80 to 9F: printable in Windows-1252, control codes in ISO 8859-1
HexWindows-1252Unicode
80€U+20AC
82‚U+201A
83ƒU+0192
84„U+201E
85…U+2026
86†U+2020
87‡U+2021
88ˆU+02C6
89‰U+2030
8AŠU+0160
8B‹U+2039
8CŒU+0152
8EŽU+017D
91‘U+2018
92’U+2019
93“U+201C
94”U+201D
95•U+2022
96–U+2013
97—U+2014
98˜U+02DC
99™U+2122
9AšU+0161
9B›U+203A
9CœU+0153
9EžU+017E
9FŸU+0178

The full 128 to 255 range for both code pages follows. The hex decoder at the top of the main page uses the same tables, so a byte above 7F decoded as ASCII is reported as an error and not guessed at.

Bytes 128 to 255 in Windows-1252 and ISO 8859-1
DecHexWindows-1252ISO 8859-1
12880€control
12981undefinedcontrol
13082‚control
13183ƒcontrol
13284„control
13385…control
13486†control
13587‡control
13688ˆcontrol
13789‰control
1388AŠcontrol
1398B‹control
1408CŒcontrol
1418Dundefinedcontrol
1428EŽcontrol
1438Fundefinedcontrol
14490undefinedcontrol
14591‘control
14692’control
14793“control
14894”control
14995•control
15096–control
15197—control
15298˜control
15399™control
1549Ašcontrol
1559B›control
1569Cœcontrol
1579Dundefinedcontrol
1589Ežcontrol
1599FŸcontrol
160A0  
161A1¡¡
162A2¢¢
163A3££
164A4¤¤
165A5¥¥
166A6¦¦
167A7§§
168A8¨¨
169A9©©
170AAªª
171AB««
172AC¬¬
173AD­­
174AE®®
175AF¯¯
176B0°°
177B1±±
178B2²²
179B3³³
180B4´´
181B5µµ
182B6
183B7··
184B8¸¸
185B9¹¹
186BAºº
187BB»»
188BC¼¼
189BD½½
190BE¾¾
191BF¿¿
192C0ÀÀ
193C1ÁÁ
194C2ÂÂ
195C3ÃÃ
196C4ÄÄ
197C5ÅÅ
198C6ÆÆ
199C7ÇÇ
200C8ÈÈ
201C9ÉÉ
202CAÊÊ
203CBËË
204CCÌÌ
205CDÍÍ
206CEÎÎ
207CFÏÏ
208D0ÐÐ
209D1ÑÑ
210D2ÒÒ
211D3ÓÓ
212D4ÔÔ
213D5ÕÕ
214D6ÖÖ
215D7××
216D8ØØ
217D9ÙÙ
218DAÚÚ
219DBÛÛ
220DCÜÜ
221DDÝÝ
222DEÞÞ
223DFßß
224E0àà
225E1áá
226E2ââ
227E3ãã
228E4ää
229E5åå
230E6ææ
231E7çç
232E8èè
233E9éé
234EAêê
235EBëë
236ECìì
237EDíí
238EEîî
239EFïï
240F0ðð
241F1ññ
242F2òò
243F3óó
244F4ôô
245F5õõ
246F6öö
247F7÷÷
248F8øø
249F9ùù
250FAúú
251FBûû
252FCüü
253FDýý
254FEþþ
255FFÿÿ

ASCII to hex: the hex value of each character

To write text as hex, look up the code of each character and write it in base 16. For Hi! the codes are 72, 105 and 33 in decimal, which are 48, 69 and 21 in hex, so the string is 48 69 21. Each character is one byte because all three are below 128. The same string in UTF-8 gives the same bytes, since UTF-8 was designed to agree with ASCII.

Characters beyond ASCII are where this stops being a table lookup, because their bytes depend on the encoding. To convert longer text, use the ASCII to hex converter; to go the other way, paste hex into the hex to ASCII decoder.

What is ASCII?

ASCII, the American Standard Code for Information Interchange, assigns a number from 0 to 127 to each of 128 characters, so that machines from different makers could exchange text. It was first published in 1963 as ASA X3.4-1963 and was revised several times; the 1967 revision added lower case letters, and the version still cited is ANSI X3.4-1986. The code grew out of telegraph and teleprinter practice, which is where the control characters come from.

Seven bits was a deliberate economy. Each transmitted character cost line time, and the eighth bit in an 8-bit byte could carry a parity check. Network documents adopted the code early; RFC 20, from 1969, describes it for use between networked computers and is still a readable summary of the table. Nearly every text protocol since, from SMTP to HTTP headers, defines its syntax in terms of ASCII.

ASCII compared with Unicode and UTF-8

Unicode is a catalogue of more than 150,000 characters, each with a code point. Its first 128 code points are ASCII, in the same order, so U+0041 is the capital A and U+000A is the line feed. A character set is not a file format, so Unicode also needs an encoding that turns code points into bytes. UTF-8, the encoding used by almost all web pages, writes the code points below 128 as single bytes with the ASCII values and uses two to four bytes for the rest.

ASCII inside Unicode and UTF-8ASCII covers the first 128 Unicode code points, U+0000 to U+007F. UTF-8 stores exactly those code points as single bytes with the same values, then uses two, three and four bytes for the rest of Unicode.Unicode code pointsASCII 0–127everything else in UnicodeUTF-8 bytes per character1 byteU+0000–007F2 bytesto U+07FF3 bytesto U+FFFF4 bytesto U+10FFFF
Not to scale. A file that contains only ASCII characters is already valid UTF-8, byte for byte.

This is the reason a plain ASCII file opens correctly as UTF-8 and why programs that only expect ASCII mostly survive UTF-8 input. It does not work in the other direction: a UTF-8 file with accented letters or emoji is not ASCII, and an ASCII-only tool will show those bytes as garbage or reject them. UTF-16 and UTF-32 do not share this property; in them the letter A is 41 00 or 00 41 and 00 00 00 41, never a bare 41.

ASCII codes in HTML, CSS and source code

An ASCII code can be written into HTML, CSS, URLs and most programming languages with an escape that contains its number. The notation differs by language but the number is the same. HTML takes decimal or hex numeric references, CSS takes a hex escape of up to six digits (and a space after a short escape ends it), C, Python and JavaScript string literals take \x followed by two hex digits, and URLs take a percent sign and two hex digits.

One character, written six ways
CharDecHexHTML decimalHTML hexC, Python, JSCSSURL
A6541&#65;&#x41;\x41\41%41
a9761&#97;&#x61;\x61\61%61
04830&#48;&#x30;\x30\30%30
space3220&#32;&#x20;\x20\20%20
!3321&#33;&#x21;\x21\21%21
"3422&#34;&#x22;\x22\22%22
&3826&#38;&#x26;\x26\26%26
<603C&#60;&#x3C;\x3C\3c%3C
~1267E&#126;&#x7E;\x7E\7e%7E

In URLs the characters that must be escaped are the ones that carry meaning in the syntax or are not allowed at all, such as the space (%20), the quotation mark (%22) and the angle brackets. RFC 3986 lists them. In HTML text the characters that need a reference are <, > and &, plus the quotation mark inside attribute values.

Typing ASCII characters with Alt codes on Windows

On Windows, holding Alt and typing a number on the numeric keypad enters the character with that code. Alt+65 types A. The leading zero matters above 127: without it Windows uses the old IBM code page 437, so Alt+233 types Θ on a US system, while Alt+0233 uses Windows-1252 and types é. Laptops without a numeric keypad need the Fn layer or an on-screen keypad. On macOS the Option key combinations and the Character Viewer do the same job without codes.

Questions about the ASCII table

How many characters are in the ASCII table?

128: codes 0 to 127. Of these, 33 are control codes (0 to 31 and 127) and 95 are printable, counting the space. The printable set is 52 letters, 10 digits, 32 punctuation and symbol characters, and the space.

What is the ASCII code for A, a and 0?

Capital A is 65 (hex 41), lower case a is 97 (hex 61), and the digit character 0 is 48 (hex 30). The digit 0 and the NUL control code, which is code 0, are different characters.

Why do uppercase and lowercase letters differ by 32?

The letters are laid out so that case is one bit. Capital letters start at 65 (binary 0100 0001) and lower case at 97 (0110 0001); the only difference is the bit worth 32. Flipping that bit changes the case, which is how early software could compare letters without regard to case with a single mask.

Is the ASCII table the same as extended ASCII?

No. ASCII ends at 127. Extended ASCII is a loose name for several different 8-bit code pages that agree with ASCII for 0 to 127 and disagree above it, such as ISO 8859-1, Windows-1252 and IBM code page 437. A byte like E9 is é in the first two and Θ in the last.

What does the DEL character do?

DEL is code 127, all seven bits set. On paper tape, punching every hole in a position erased whatever was punched there, so DEL meant "ignore this". Today many Unix terminals send it when you press Backspace, and most other software treats it as a character to be dropped.