How Text Is Stored as Binary: ASCII, Unicode and UTF-8 Explained

Understand how letters become ones and zeros, why ASCII uses 7 bits, how UTF-8 encodes accents, scripts and emoji in 1 to 4 bytes, and how to decode binary back.

Updated September 29, 2026 5 min read

Use the free Text to Binary ConverterConvert text to binary, hex, octal or decimal and back

A puzzle in an escape room hands you a strip of ones and zeros. A computing class asks you to write your name in binary. A developer finds 48 65 6C 6C 6F in a network capture and wants to know what it says. Each of these depends on the same basic idea: computers store text as numbers, and those numbers are stored as bits.

This guide explains how characters are mapped to numbers, how ASCII and Unicode differ, why UTF-8 uses a variable number of bytes, and how to convert text to binary, hex, octal or decimal and back. It also covers the errors you are likely to see when something has been decoded the wrong way.

From characters to numbers

A computer has no concept of the letter A. It only stores numbers. A character set is an agreed table that assigns a number to every character, and an encoding is the rule for turning those numbers into bytes.

ASCII

ASCII, from the 1960s, assigns numbers 0 to 127 to English letters, digits, punctuation and control characters. It needs only 7 bits, so each character fits comfortably in one 8-bit byte:

Character Decimal Hex Binary
A 65 41 01000001
a 97 61 01100001
0 48 30 00110000
space 32 20 00100000

Notice that lowercase letters are exactly 32 more than uppercase ones, which is a single bit difference. That design made case conversion trivial on early hardware. The full table is in the ASCII table.

Unicode

ASCII has no room for é, ₹, नमस्ते or emoji. Unicode solves this with one enormous table that gives every character in every writing system a unique number, called a code point, written like U+20B9 for the rupee sign. Unicode has space for over a million code points.

UTF-8

Unicode says which number a character has; UTF-8 says how to store it. It uses one to four bytes per character:

Code point range Bytes Examples
U+0000 to U+007F 1 English letters, digits (identical to ASCII)
U+0080 to U+07FF 2 é, ñ, Greek, Cyrillic, Arabic, Hebrew
U+0800 to U+FFFF 3 ₹, Devanagari, Chinese, Japanese
U+10000 and above 4 Most emoji, rare scripts

Because the first range matches ASCII exactly, plain English text is the same in ASCII and UTF-8. That backwards compatibility is a big reason UTF-8 became the dominant encoding on the web.

Convert text to binary and back

The Text to Binary Converter encodes text as UTF-8 bytes and shows them in the number format you choose.

  1. Open the Text to Binary Converter. It starts with a sample containing English, Hindi and an emoji so you can see multi-byte characters.
  2. Choose the direction with the two buttons at the top: Text → Binary or Binary → Text (the labels change with the number format).
  3. Pick a Number format: Binary (base 2), Hexadecimal (base 16), Octal (base 8) or Decimal (base 10).
  4. When encoding, choose a Separator between bytes: Space, None, Comma or New line. For hex output you can tick Uppercase hex digits.
  5. Type or paste into the input box. The output appears as you type; copy it with the copy button.
  6. To check a round trip, click Swap, which moves the output into the input and flips the direction.

When decoding, paste the bytes in the selected format. Separated bytes are easiest, but a continuous binary or hex string is also split into bytes automatically. If some bytes do not form valid UTF-8, they are shown as the replacement character � and the tool warns you.

Other ways to convert text

Command line

On Linux or macOS, xxd shows the bytes of any text:

echo -n "Hi" | xxd -b     # binary: 01001000 01101001
echo -n "Hi" | xxd        # hex: 4869

Programming languages

Python makes the steps explicit:

"Hi ₹".encode("utf-8")              # b'Hi \xe2\x82\xb9'
" ".join(f"{b:08b}" for b in "Hi".encode())   # '01001000 01101001'
bytes.fromhex("48 69").decode()     # 'Hi'

In JavaScript, new TextEncoder().encode(text) gives the UTF-8 bytes.

Spreadsheets

CODE() or UNICODE() returns a character's number, and DEC2BIN() converts it. This works letter by letter, but it is clumsy for whole sentences and does not show UTF-8 bytes.

Command-line tools and code are the better choice for files and automation. A browser converter is faster for puzzles, homework and short snippets.

Tips and troubleshooting

Characters versus bytes

"नमस्ते" looks like a few characters, but in UTF-8 it is 18 bytes, because each Devanagari code point takes three bytes and the word is made of six code points including vowel signs. Many emoji are four bytes, and some, like family or flag emoji, are several code points joined together. This is why databases and APIs that limit "characters" sometimes reject text that looks short.

Garbled text (mojibake)

Seeing é instead of é means UTF-8 bytes were read as a single-byte encoding such as Windows-1252. Converting the text to hex and checking the bytes (é should be C3 A9) is a quick way to prove what really happened.

Binary numbers versus binary text

Converting the number 42 gives 101010. Converting the text "42" gives two bytes, 00110100 00110010, one for each digit character. For numbers, use a number base converter.

Binary is not encryption

Binary or hex encoding hides nothing; anyone can decode it. For compact transport of bytes, Base64 is more common, and for fingerprints of data use a hash generator.

Frequently asked questions

What is "hello" in binary?

In ASCII and UTF-8, "hello" is 01101000 01100101 01101100 01101100 01101111: one byte for each letter.

Why are binary bytes written with 8 digits?

A byte has 8 bits. Writing leading zeros, such as 01000001 for A, keeps every byte the same width so the sequence can be split and read reliably.

Is ASCII the same as UTF-8?

For the first 128 characters, yes: the bytes are identical. UTF-8 extends ASCII with multi-byte sequences for every other Unicode character.

How many bytes does an emoji take?

Most single emoji are 4 bytes in UTF-8. Emoji built from several code points, such as flags or skin-tone variants, take more.

Why does my decoded text show � symbols?

The bytes are not valid UTF-8, often because a byte was missing, mistyped, or the data was in a different encoding to begin with.

Try it now: Text to Binary Converter

Loading tool…