ASCII Codes: Complete Reference Guide for Developers
Table of Contents
- What is ASCII? A Brief History
- ASCII Code Categories
- Printable ASCII Characters Table (32–126)
- Control Characters Explained (0–31)
- Extended ASCII (128–255)
- ASCII vs Unicode vs UTF-8
- How to Type ASCII Characters
- ASCII in Programming
- ASCII Art: Creative Text Graphics
- Common ASCII Values Every Developer Should Know
Whether you are debugging a file encoding issue, working with low-level network protocols, or just trying to remember whether uppercase ‘A’ is 65 or 97, ASCII codes are something every developer encounters regularly. This guide covers everything you need to know about the ASCII character set, from its 1960s origins to practical usage in modern programming languages.
Interactive ASCII Table Tool
Need to look up ASCII codes quickly? Try our interactive ASCII Table tool for instant decimal, hexadecimal, octal, and binary conversions of every ASCII character.
1. What is ASCII? A Brief History
ASCII stands for American Standard Code for Information Interchange. It is a character encoding standard that assigns numeric values to letters, digits, punctuation marks, and control characters. First published as a standard in 1963 by the American Standards Association (now ANSI), ASCII became the foundation for virtually all modern character encoding systems.
Before ASCII existed, different computer manufacturers used their own proprietary character encoding schemes. IBM used EBCDIC, while other systems had their own incompatible codes. This made it nearly impossible to exchange text data between different computer systems. ASCII solved this problem by providing a universal standard that everyone could agree on.
Key Facts About ASCII
- 7-bit encoding: ASCII uses 7 bits to represent each character, giving exactly 128 possible values (0 through 127). This was deliberate — the 8th bit of each byte was originally reserved for parity checking in data transmission.
- 128 characters total: These include 33 control characters (non-printable), 1 delete character, and 95 printable characters (letters, digits, punctuation, and space).
- Based on English: ASCII was designed around the English alphabet, which became both its strength (simplicity) and its limitation (no accented characters, no CJK scripts, no emoji).
- Backward compatible: Every major encoding system that came after (Latin-1, Windows-1252, UTF-8) maintains ASCII as a subset. A valid ASCII file is also a valid UTF-8 file.
The original ASCII standard went through several revisions. The 1963 version lacked lowercase letters (yes, really). The 1967 revision, known as ANSI X3.4-1967, added lowercase letters and finalized the character set we know today. The most recent formal revision is ANSI X3.4-1986, though the character set has remained unchanged since 1967.
2. ASCII Code Categories
The 128 ASCII characters are divided into three main categories:
| Range | Category | Count | Description |
|---|---|---|---|
| 0–31 | Control Characters | 32 | Non-printable characters that control text processing (newlines, tabs, bell, etc.) |
| 32–126 | Printable Characters | 95 | Letters, digits, punctuation, and the space character |
| 127 | DEL (Delete) | 1 | Originally used to “punch out” erroneous characters on paper tape |
The printable range (32–126) is what you interact with every day when typing. It breaks down further into:
- Space (32) — the most common character in most text
- Digits 0–9 (48–57) — conveniently, subtracting 48 from the ASCII code gives the numeric value
- Uppercase A–Z (65–90) — 26 letters
- Lowercase a–z (97–122) — 26 letters, exactly 32 higher than their uppercase equivalents
- Punctuation & symbols (33–47, 58–64, 91–96, 123–126) — everything else
The 32-Offset Trick
The difference between uppercase and lowercase letters is always exactly 32. That means you can toggle case with a single XOR operation: char ^ 32. This is because bit 5 (value 32) is the only bit that differs between ‘A’ (01000001) and ‘a’ (01100001). This was an intentional design decision by the ASCII creators.
3. Printable ASCII Characters Quick Reference (32–126)
This is the complete table of all 95 printable ASCII characters. Use our ASCII Table tool for an interactive version with search and filtering, or use the Number Base Converter to translate between decimal, hex, octal, and binary.
| Dec | Hex | Char | Dec | Hex | Char | Dec | Hex | Char | ||
|---|---|---|---|---|---|---|---|---|---|---|
| 32 | 20 | ␣ | 64 | 40 | @ | 96 | 60 | ` | ||
| 33 | 21 | ! | 65 | 41 | A | 97 | 61 | a | ||
| 34 | 22 | " | 66 | 42 | B | 98 | 62 | b | ||
| 35 | 23 | # | 67 | 43 | C | 99 | 63 | c | ||
| 36 | 24 | $ | 68 | 44 | D | 100 | 64 | d | ||
| 37 | 25 | % | 69 | 45 | E | 101 | 65 | e | ||
| 38 | 26 | & | 70 | 46 | F | 102 | 66 | f | ||
| 39 | 27 | ' | 71 | 47 | G | 103 | 67 | g | ||
| 40 | 28 | ( | 72 | 48 | H | 104 | 68 | h | ||
| 41 | 29 | ) | 73 | 49 | I | 105 | 69 | i | ||
| 42 | 2A | * | 74 | 4A | J | 106 | 6A | j | ||
| 43 | 2B | + | 75 | 4B | K | 107 | 6B | k | ||
| 44 | 2C | , | 76 | 4C | L | 108 | 6C | l | ||
| 45 | 2D | - | 77 | 4D | M | 109 | 6D | m | ||
| 46 | 2E | . | 78 | 4E | N | 110 | 6E | n | ||
| 47 | 2F | / | 79 | 4F | O | 111 | 6F | o | ||
| 48 | 30 | 0 | 80 | 50 | P | 112 | 70 | p | ||
| 49 | 31 | 1 | 81 | 51 | Q | 113 | 71 | q | ||
| 50 | 32 | 2 | 82 | 52 | R | 114 | 72 | r | ||
| 51 | 33 | 3 | 83 | 53 | S | 115 | 73 | s | ||
| 52 | 34 | 4 | 84 | 54 | T | 116 | 74 | t | ||
| 53 | 35 | 5 | 85 | 55 | U | 117 | 75 | u | ||
| 54 | 36 | 6 | 86 | 56 | V | 118 | 76 | v | ||
| 55 | 37 | 7 | 87 | 57 | W | 119 | 77 | w | ||
| 56 | 38 | 8 | 88 | 58 | X | 120 | 78 | x | ||
| 57 | 39 | 9 | 89 | 59 | Y | 121 | 79 | y | ||
| 58 | 3A | : | 90 | 5A | Z | 122 | 7A | z | ||
| 59 | 3B | ; | 91 | 5B | [ | 123 | 7B | { | ||
| 60 | 3C | < | 92 | 5C | \ | 124 | 7C | | | ||
| 61 | 3D | = | 93 | 5D | ] | 125 | 7D | } | ||
| 62 | 3E | > | 94 | 5E | ^ | 126 | 7E | ~ | ||
| 63 | 3F | ? | 95 | 5F | _ |
Note: Character 32 is the space character, shown here as ␣ (open box symbol) for visibility.
4. Control Characters Explained (0–31)
The first 32 ASCII codes (0–31) are control characters. They were originally designed to control teletype machines and printers rather than represent printable symbols. While most are obsolete today, several remain critically important in modern computing.
Most Important Control Characters
| Dec | Hex | Abbr | Name | Escape | Modern Usage |
|---|---|---|---|---|---|
| 0 | 00 | NUL | Null | \0 | String terminator in C/C++ |
| 7 | 07 | BEL | Bell | \a | Terminal alert/beep sound |
| 8 | 08 | BS | Backspace | \b | Move cursor back one position |
| 9 | 09 | HT | Horizontal Tab | \t | Tab character in code and text |
| 10 | 0A | LF | Line Feed | \n | Newline on Unix/Linux/macOS |
| 11 | 0B | VT | Vertical Tab | \v | Rarely used; vertical spacing |
| 12 | 0C | FF | Form Feed | \f | Page break in printing |
| 13 | 0D | CR | Carriage Return | \r | Used with LF for Windows newlines (\r\n) |
| 27 | 1B | ESC | Escape | \e | Start of ANSI escape sequences for terminal colors |
Complete Control Characters Table (0–31 + 127)
| Dec | Hex | Abbr | Name | Dec | Hex | Abbr | Name | |
|---|---|---|---|---|---|---|---|---|
| 0 | 00 | NUL | Null | 16 | 10 | DLE | Data Link Escape | |
| 1 | 01 | SOH | Start of Heading | 17 | 11 | DC1 | Device Control 1 (XON) | |
| 2 | 02 | STX | Start of Text | 18 | 12 | DC2 | Device Control 2 | |
| 3 | 03 | ETX | End of Text | 19 | 13 | DC3 | Device Control 3 (XOFF) | |
| 4 | 04 | EOT | End of Transmission | 20 | 14 | DC4 | Device Control 4 | |
| 5 | 05 | ENQ | Enquiry | 21 | 15 | NAK | Negative Acknowledge | |
| 6 | 06 | ACK | Acknowledge | 22 | 16 | SYN | Synchronous Idle | |
| 7 | 07 | BEL | Bell | 23 | 17 | ETB | End of Trans. Block | |
| 8 | 08 | BS | Backspace | 24 | 18 | CAN | Cancel | |
| 9 | 09 | HT | Horizontal Tab | 25 | 19 | EM | End of Medium | |
| 10 | 0A | LF | Line Feed | 26 | 1A | SUB | Substitute | |
| 11 | 0B | VT | Vertical Tab | 27 | 1B | ESC | Escape | |
| 12 | 0C | FF | Form Feed | 28 | 1C | FS | File Separator | |
| 13 | 0D | CR | Carriage Return | 29 | 1D | GS | Group Separator | |
| 14 | 0E | SO | Shift Out | 30 | 1E | RS | Record Separator | |
| 15 | 0F | SI | Shift In | 31 | 1F | US | Unit Separator | |
| 127 | 7F | DEL | Delete | |||||
The Newline Problem: LF vs CR vs CRLF
One of the most enduring headaches in computing comes from how different operating systems handle line endings:
- Unix/Linux/macOS: LF only (
\n, ASCII 10) - Windows: CR+LF (
\r\n, ASCII 13 + 10) - Classic Mac OS (pre-2001): CR only (
\r, ASCII 13)
This is why Git has core.autocrlf settings — to automatically convert line endings between platforms. If you have ever seen ^M characters at the end of lines in a terminal, those are carriage return characters from a Windows-formatted file.
5. Extended ASCII (128–255)
Standard ASCII only defines 128 characters using 7 bits. Since a byte has 8 bits, the remaining 128 values (128–255) were up for grabs. Various “extended ASCII” encodings filled this space differently, leading to widespread incompatibility.
Major Extended ASCII Encodings
| Encoding | Range | Key Characters | Usage |
|---|---|---|---|
| ISO 8859-1 (Latin-1) | 128–255 | é ñ ü ß ø £ €* | Western European languages, early web standard |
| Windows-1252 | 128–255 | “ ” ‘ ’ — – … ™ | Windows default; adds curly quotes and dashes where Latin-1 has control codes (128–159) |
| ISO 8859-15 (Latin-9) | 128–255 | € Š š Œ œ | Updated Latin-1 with Euro sign |
| Code Page 437 | 128–255 | Box-drawing characters: ─ │ ┌ ┐ | Original IBM PC; DOS-era box drawing and graphics |
* The Euro sign (€) is not in original Latin-1; it was added at position 164 in Latin-9, and at position 128 in Windows-1252.
Why “Extended ASCII” Is Not Really a Standard
Strictly speaking, there is no single “extended ASCII” standard. The term informally refers to any 8-bit encoding that keeps ASCII in the lower 128 values and adds more characters in 128–255. Because different systems used different mappings for those upper values, you could never be sure what character 0xE9 meant without knowing the encoding. This chaos is exactly what Unicode was created to solve.
6. ASCII vs Unicode vs UTF-8
Understanding the relationship between ASCII, Unicode, and UTF-8 is essential for modern development. Here is how they relate:
| Feature | ASCII | Unicode | UTF-8 |
|---|---|---|---|
| What is it? | Character encoding | Character set (abstract) | Encoding of Unicode |
| Characters | 128 | 149,813+ (Unicode 16.0) | All Unicode characters |
| Bits per char | 7 bits (fixed) | N/A (abstract code points) | 1–4 bytes (variable) |
| ASCII compatible? | Yes (is ASCII) | Yes (first 128 code points) | Yes (single byte for 0–127) |
| Languages | English only | All modern scripts + historic | All modern scripts + historic |
| Emoji support | No | Yes | Yes (4 bytes each) |
| Web usage (2026) | <1% | N/A | ~98% of all websites |
Unicode is not an encoding — it is a catalog that assigns a unique number (called a code point) to every character in every writing system. Code points are written as U+0041 (for ‘A’). UTF-8 is the most popular way to encode those code points into bytes for storage and transmission.
The genius of UTF-8 is that it is fully backward-compatible with ASCII. Any valid ASCII text is also valid UTF-8, because UTF-8 encodes ASCII characters 0–127 as a single byte with the same value. Characters beyond ASCII use 2, 3, or 4 bytes. This means you can safely serve ASCII files as UTF-8 without changing a single byte.
For working with encoded data in your projects, check out our Base64 Encoder/Decoder and Hash Generator tools.
7. How to Type ASCII Characters
Sometimes you need to enter a character that is not on your keyboard. Here are the methods for each major operating system:
Windows: Alt Codes
Hold Alt and type the decimal ASCII code on the numeric keypad (not the top row):
| Combination | Character | Description |
|---|---|---|
| Alt + 64 | @ | At sign |
| Alt + 92 | \ | Backslash |
| Alt + 124 | | | Pipe |
| Alt + 126 | ~ | Tilde |
| Alt + 0169 | © | Copyright (extended, Windows-1252) |
| Alt + 0176 | ° | Degree sign (extended) |
Important: Alt + 65 and Alt + 0065 can produce different characters in the extended range (128–255) because the first uses Code Page 437 and the second uses Windows-1252.
macOS: Unicode Hex Input
- Enable “Unicode Hex Input” in System Settings > Keyboard > Input Sources
- Hold Option and type the 4-digit hex code: Option +
0041for ‘A’
Linux: Ctrl+Shift+U
- Press Ctrl+Shift+U
- Type the hex code (e.g.,
41for ‘A’) - Press Enter or Space
HTML: Character References
In HTML, you can use either decimal or hexadecimal references:
<!-- Decimal reference -->
A → A
© → ©
<!-- Hexadecimal reference -->
A → A
© → ©
<!-- Named entities (selected characters) -->
& → &
< → <
> → >
" → "
8. ASCII in Programming: Escape Sequences & Char Codes
Every programming language provides ways to work with ASCII character codes. Here are practical examples in the most popular languages:
JavaScript
JavaScript
// Get ASCII code of a character
'A'.charCodeAt(0); // 65
'a'.charCodeAt(0); // 97
'0'.charCodeAt(0); // 48
' '.charCodeAt(0); // 32
// Get character from ASCII code
String.fromCharCode(65); // 'A'
String.fromCharCode(10); // '\n' (newline)
// Check if a character is uppercase
function isUpper(ch) {
const code = ch.charCodeAt(0);
return code >= 65 && code <= 90;
}
// Convert uppercase to lowercase (add 32)
String.fromCharCode('A'.charCodeAt(0) + 32); // 'a'
// Escape sequences
'\n' // newline (LF, ASCII 10)
'\t' // tab (HT, ASCII 9)
'\x41' // hex escape: 'A'
'\u0041' // unicode escape: 'A'
Python
Python
# Get ASCII code of a character
ord('A') # 65
ord('z') # 122
ord('\n') # 10
# Get character from ASCII code
chr(65) # 'A'
chr(48) # '0'
# Check if string is ASCII-only
'Hello'.isascii() # True
'Café'.isascii() # False
# Print full ASCII table
for i in range(32, 127):
print(f"{i:3d} 0x{i:02X} {chr(i)}")
# Escape sequences
'\n' # newline
'\t' # tab
'\x41' # hex escape: 'A'
'\101' # octal escape: 'A'
C / C++
C
// Characters ARE their ASCII codes in C
char c = 'A'; // c == 65
int code = 'A'; // code == 65
char lower = 'A' + 32; // lower == 'a'
// Toggle case with XOR
char toggled = 'A' ^ 32; // 'a'
toggled = 'a' ^ 32; // 'A'
// Check if digit (the classic way)
if (c >= '0' && c <= '9') {
int digit = c - '0'; // convert char to int
}
// Common escape sequences
'\n' // newline (10)
'\r' // carriage return (13)
'\t' // tab (9)
'\0' // null terminator (0)
'\x1B' // escape character (27)
'\\' // literal backslash (92)
Convert Between Number Bases
Need to convert ASCII codes between decimal, hexadecimal, octal, and binary? Use our Number Base Converter tool for instant conversions.
9. ASCII Art: Creative Text Graphics
ASCII art is the practice of creating images and designs using only the 95 printable ASCII characters. It dates back to the days of typewriters and early computer terminals when graphical displays were unavailable. Despite being decades old, ASCII art remains popular in README files, terminal UIs, email signatures, and developer culture.
Classic ASCII Art Examples
/\_/\
( o.o )
> ^ <
/| |\
(_| |_)
Cat
_____
| |
| | | |
|_____|
| |
| |
|_____|
Floppy
Disk
.---------.
|.-------.|
|| ||
|| ||
|"-------"|
/---------\
/ _________ \
/ / \ \
(___/_________\__)
Computer
ASCII Art Techniques
ASCII artists use different characters to create shading and depth. The key concept is character density — some characters appear darker (more ink) than others:
// From lightest to darkest (commonly used gradient):
.:-=+*#%@
// Extended density scale:
.'`^",:;Il!i><~+_-?][}{1)(|\/tfjrxnuvczXYUJCLQ0OZmwqpdbkhao*#MW&8%B@$
Modern ASCII art generators convert images to text by mapping pixel brightness to characters from this density scale. The darker the pixel, the denser the character used.
Box-Drawing with ASCII
Before Unicode box-drawing characters existed, developers used ASCII characters to create borders and tables in terminal applications:
+----------+----------+----------+
| Name | Age | Role |
+----------+----------+----------+
| Alice | 30 | Dev |
| Bob | 25 | Design |
+----------+----------+----------+
This technique is still used today in CLI tools, logging output, and documentation. Tools like tree, htop, and git log --graph all use character-based graphics.
10. Common ASCII Values Every Developer Should Know
You do not need to memorize all 128 ASCII codes, but knowing these key values will save you time when debugging, writing parsers, or working with binary data:
Quick Mental Math Tricks
- Uppercase → Lowercase: Add 32 (A=65 → a=97)
- Lowercase → Uppercase: Subtract 32 (a=97 → A=65)
- Digit char → Number: Subtract 48 (‘7’=55 → 7)
- Toggle case with XOR:
char ^ 32flips between upper and lower - Letter position in alphabet: Subtract 64 from uppercase (A=1, B=2 … Z=26) or 96 from lowercase
Common Ranges to Remember
| Characters | Decimal Range | Hex Range | Quick Check |
|---|---|---|---|
| Digits 0–9 | 48–57 | 0x30–0x39 | c >= '0' && c <= '9' |
| Uppercase A–Z | 65–90 | 0x41–0x5A | c >= 'A' && c <= 'Z' |
| Lowercase a–z | 97–122 | 0x61–0x7A | c >= 'a' && c <= 'z' |
| All printable | 32–126 | 0x20–0x7E | c >= ' ' && c <= '~' |
| Whitespace | 9–13, 32 | 0x09–0x0D, 0x20 | isspace(c) |
Summary
ASCII may be over 60 years old, but it remains the bedrock of text encoding in computing. Every UTF-8 document, every JSON API response, every line of source code builds on top of those original 128 character codes. Understanding ASCII is not just trivia — it is a practical skill that helps you debug encoding issues, write more efficient parsers, and understand how text is represented at the byte level.
Key Takeaways
- ASCII defines 128 characters: 33 control characters, 94 printable characters, and the space and DEL characters
- The printable range (32–126) covers everything you type on an English keyboard
- The upper/lowercase offset of 32 was intentionally designed for easy bit manipulation
- UTF-8 is a superset of ASCII — every ASCII file is already valid UTF-8
- Extended ASCII (128–255) varies by encoding; always specify your encoding explicitly
- Key values to remember: Space=32, 0=48, A=65, a=97
DevToolbox ASCII & Encoding Tools
Put your ASCII knowledge to work with our free developer tools:
- ASCII Table — Interactive lookup for all 128 ASCII characters
- Base64 Encoder/Decoder — Encode and decode Base64 strings
- Hash Generator — Generate MD5, SHA-1, SHA-256 hashes
- Number Base Converter — Convert between decimal, hex, octal, binary