Encoding 7 min read
Computers only understand numbers, so every letter, digit and symbol you see on screen is stored as a number. ASCII is the classic agreement on which number means which character, and it is still hiding inside almost every text file, web page and program today.
In this guide you will learn what ASCII is, how its codes are organized, why accents used to break, how Unicode and UTF-8 solved the problem and how to look up the code of any character in seconds.
Look up any ASCII code Browse the full ASCII table with decimal, hexadecimal, binary and character values. Free, and it runs in your browser. Open the ASCII tableWhat is ASCII?
ASCII stands for American Standard Code for Information Interchange. It was developed in the 1960s so that different machines could exchange text without confusion, and it assigns a number to each character.
It is a 7-bit code, which means it has 128 possible values, from 0 to 127. That is enough for the English alphabet in upper and lower case, the digits 0 to 9, punctuation marks and a set of special control codes.
Control characters and printable characters
The 128 codes are split into two groups. Codes 0 to 31, plus 127, are control characters: they do not draw anything, they give instructions to a device. Codes 32 to 126 are the 95 printable characters you actually see.
Some values worth knowing:
- 32 is the space character.
- 48 to 57 are the digits 0 to 9 (so "0" is 48).
- 65 to 90 are the capital letters A to Z (so "A" is 65).
- 97 to 122 are the lowercase letters a to z (so "a" is 97).
- 10 is the newline (line feed), 13 is the carriage return and 9 is the tab.
- 0 is the null character, 27 is Escape and 127 is Delete.
The trick behind upper and lower case
Look at "A" (65) and "a" (97): they differ by exactly 32. The same is true for every letter pair, so "B" is 66 and "b" is 98. In binary, that difference is a single bit, which makes converting between cases very cheap for a computer.
Digits follow a pattern too. Since "0" is 48, you can turn the character of a digit into its numeric value by subtracting 48. This is a classic trick in programming.
Tip: to convert a letter to lowercase in ASCII, add 32 to its code. To convert to uppercase, subtract 32.
Extended ASCII and code pages: why accents broke
Computers store data in 8-bit bytes, so there was room for 128 more values (128 to 255). Different vendors and countries filled that space in different ways, creating "code pages" such as ISO-8859-1 for Western European languages or Windows-1252.
These are often called extended ASCII, but there is no single standard: the same number could be an "é" in one code page and a completely different symbol in another. Text written in one system could look wrong in another, and languages with thousands of characters did not fit at all.
Unicode: a number for every character
Unicode solved this by giving every character in every writing system its own unique number, called a code point, written like U+0041 for "A". It covers Latin, Cyrillic, Chinese, Arabic, Devanagari, Bengali and many more scripts, as well as symbols and emoji.
The first 128 Unicode code points are identical to ASCII, so "A" is 65 in both. Unicode is a catalog of characters; how those numbers are saved as bytes is a separate matter, handled by an encoding.
UTF-8: the encoding that took over the web
UTF-8 is the most common way to store Unicode. It uses a variable length of 1 to 4 bytes per character: ASCII characters take just one byte, identical to the old ASCII, while accented letters usually take two, many other scripts take three and emoji take four.
Because plain ASCII text is already valid UTF-8, old files and new ones work together. That compatibility is the main reason UTF-8 became the default for web pages, source code and most modern systems.
Why garbled text (mojibake) happens
Mojibake appears when text is saved with one encoding and read with another. A classic example: the word "café" saved as UTF-8 but opened as Windows-1252 shows up as "café", because the two bytes of "é" are read as two separate characters.
The fix is almost always to make both sides agree. Declare UTF-8 in your web page, save files as UTF-8 and make sure databases and tools use the same encoding.
Where ASCII is still useful
Knowing ASCII helps in everyday technical work. Developers use character codes to compare and sort text, validate input, build parsers and write escape sequences such as \n for a newline or \t for a tab.
- Protocols and file formats such as HTTP headers, JSON and CSV rely on ASCII characters for their structure.
- Terminals use the Escape character (27) to start color and cursor commands.
- Passwords, URLs and identifiers are often limited to ASCII to avoid compatibility problems.
- Debugging: seeing the code of a mysterious character shows whether it is a space, a tab or an invisible symbol.
How to find a character code in 3 steps
- Open the free ASCII table in your browser.
- Find the character you want, or search by its decimal, hexadecimal or binary value.
- Copy the code in the format you need, such as decimal for programming or hexadecimal for a byte editor.
Common mistakes to avoid
- Assuming "extended ASCII" is one standard. It is not; it depends on the code page.
- Saving a file in one encoding and opening it in another.
- Confusing a character with a byte: in UTF-8, one character can take up to 4 bytes.
- Mixing up the digit "0" (code 48) with the number 0 or the null character (code 0).
- Forgetting the invisible control characters, such as carriage return (13) and newline (10), when comparing text from different systems.
Conclusion
ASCII is a small, elegant code of 128 characters that still sits at the base of modern computing. Unicode extended the idea to every language and emoji, and UTF-8 made it practical while staying compatible with ASCII. When you meet strange symbols or need a character code, remember it is only a matter of matching encodings, and the free table is one click away.
Frequently asked questions
How many characters does ASCII have?
Standard ASCII has 128 characters, numbered 0 to 127: 33 control codes (0 to 31 and 127) and 95 printable characters, including the space.
What is the difference between ASCII and Unicode?
ASCII covers only 128 characters, mainly for English. Unicode assigns a unique number to characters from virtually all writing systems, plus symbols and emoji. The first 128 Unicode code points are the same as ASCII.
Is UTF-8 the same as Unicode?
No. Unicode is the catalog of characters and their numbers, while UTF-8 is one way of storing those numbers as bytes. Other encodings, such as UTF-16, exist, but UTF-8 is the most widely used on the web.
What is the ASCII code of the letter A?
Capital "A" is 65 in decimal (41 in hexadecimal) and lowercase "a" is 97 (61 in hexadecimal). The difference between them is always 32.
Why do accents turn into strange symbols?
Usually because the text was saved in one encoding, such as UTF-8, and opened in another, such as Windows-1252. Using the same encoding on both sides, preferably UTF-8, fixes it.
Free tools mentioned in this article
Keep reading
- How to Create a Strong PasswordLength, randomness and uniqueness: the simple rules that actually protect your accounts, and how to follow them without memorizing a thing.
- The Pomodoro Technique: Complete GuideWork in focused 25-minute blocks with short breaks. Learn how the method works, how to start today and how to adapt it to your routine.
- What Is a Hash? MD5, SHA-256 and What They Are Used ForA hash is a short fingerprint of any data. Learn how it works, which algorithms to trust and how to use hashes to verify files and protect passwords.