Text to Binary
Both ways · UTF-8 · Hex · ASCII
Try:
Type text in the first box, or paste code in the second.
Every character, byte by byte

The characters of your text appear here.

How text becomes binary

A computer can only store numbers, so every character has a number. The letter A is 65, a is 97, a space is 32 and the digit 0 is 48. These numbers come from ASCII (1963), and Unicode kept them and added numbers for every other script and for emoji.

To store the number, it is written in base 2 and saved as one or more bytes of 8 bits. 65 is 64 + 1, so A is 01000001. The rule that turns a Unicode number into bytes is the encoding. Almost the whole web uses UTF-8.

Example: "Hi!"

CharacterNumberBinaryHex
H72 = 64 + 80100100048
i105 = 64 + 32 + 8 + 10110100169
!33 = 32 + 10010000121

So "Hi!" is 01001000 01101001 00100001. Capital and small letters are exactly 32 apart, so they differ in one bit: H is 01001000 and h is 01101000.

How to read binary as text by hand

  1. Split the bits into bytes of 8, from the left: 0100100001101001 becomes 01001000 and 01101001. If the count is not a multiple of 8, check for a missing digit, or try groups of 7 (old 7-bit ASCII).
  2. Turn each byte into a number. The 8 places are worth 128, 64, 32, 16, 8, 4, 2 and 1. Add the places where the bit is 1: 01001000 = 64 + 8 = 72.
  3. Look the number up in the ASCII table below: 72 is H, 105 is i.
  4. Bytes that start with 110, 1110 or 11110 begin a UTF-8 character of 2, 3 or 4 bytes (é, €, emoji). Those need the converter above, or the number base converter and some patience.

ASCII, UTF-8 and UTF-16 compared

The same character gives different bytes in different encodings. This is why a text can turn into "é" or "�" when it is read with the wrong one.

CharacterCode pointUTF-8UTF-16 BELatin-1
AU+004141 (1 byte)00 4141
éU+00E9C3 A9 (2 bytes)00 E9E9
€U+20ACE2 82 AC (3 bytes)20 ACnot possible
中U+4E2DE4 B8 AD (3 bytes)4E 2Dnot possible
😀U+1F600F0 9F 98 80 (4 bytes)D8 3D DE 00not possible
  • ASCII: 128 characters (0–127), English only. Every ASCII text is also valid UTF-8 with the same bytes.
  • UTF-8: 1 to 4 bytes per character. Used by about 98% of web pages, by Linux and macOS files, JSON and most APIs.
  • UTF-16: 2 or 4 bytes per character. Used inside Windows, Java, JavaScript and C# strings. BE and LE are the two byte orders.
  • Latin-1 (ISO-8859-1): 1 byte per character, 256 characters for Western European languages. Windows-1252 is almost the same, but uses 128–159 for € and curly quotes.

ASCII table with binary, hex and decimal

The 95 printable ASCII characters. Code 32 is the space. Codes 0–31 and 127 are control codes: the most common are 9 (tab), 10 (new line, LF), 13 (carriage return, CR) and 0 (NUL).

CharDecimalHexBinaryOctal
(space)322000100000040
!332100100001041
"342200100010042
#352300100011043
$362400100100044
%372500100101045
&382600100110046
'392700100111047
(402800101000050
)412900101001051
*422A00101010052
+432B00101011053
,442C00101100054
-452D00101101055
.462E00101110056
/472F00101111057
0483000110000060
1493100110001061
2503200110010062
3513300110011063
4523400110100064
5533500110101065
6543600110110066
7553700110111067
8563800111000070
9573900111001071
:583A00111010072
;593B00111011073
<603C00111100074
=613D00111101075
>623E00111110076
?633F00111111077
@644001000000100
A654101000001101
B664201000010102
C674301000011103
D684401000100104
E694501000101105
F704601000110106
G714701000111107
H724801001000110
I734901001001111
J744A01001010112
K754B01001011113
L764C01001100114
M774D01001101115
N784E01001110116
O794F01001111117
P805001010000120
Q815101010001121
R825201010010122
S835301010011123
T845401010100124
U855501010101125
V865601010110126
W875701010111127
X885801011000130
Y895901011001131
Z905A01011010132
[915B01011011133
\925C01011100134
]935D01011101135
^945E01011110136
_955F01011111137
`966001100000140
a976101100001141
b986201100010142
c996301100011143
d1006401100100144
e1016501100101145
f1026601100110146
g1036701100111147
h1046801101000150
i1056901101001151
j1066A01101010152
k1076B01101011153
l1086C01101100154
m1096D01101101155
n1106E01101110156
o1116F01101111157
p1127001110000160
q1137101110001161
r1147201110010162
s1157301110011163
t1167401110100164
u1177501110101165
v1187601110110166
w1197701110111167
x1207801111000170
y1217901111001171
z1227A01111010172
{1237B01111011173
|1247C01111100174
}1257D01111101175
~1267E01111110176

Text to binary in code

LanguageText to binary (UTF-8)Binary to text
JavaScript[...new TextEncoder().encode(s)].map(b => b.toString(2).padStart(8, '0')).join(' ')new TextDecoder().decode(new Uint8Array(bits.split(' ').map(b => parseInt(b, 2))))
Python' '.join(f'{b:08b}' for b in s.encode())bytes(int(b, 2) for b in bits.split()).decode()
JavaString.format("%8s", Integer.toBinaryString(b & 0xFF)).replace(' ', '0') for each byte of s.getBytes(UTF_8)(byte) Integer.parseInt(bits, 2) per byte, then new String(bytes, UTF_8)
C#string.Join(" ", Encoding.UTF8.GetBytes(s).Select(b => Convert.ToString(b, 2).PadLeft(8, '0')))Encoding.UTF8.GetString(bits.Split(' ').Select(b => Convert.ToByte(b, 2)).ToArray())
Gofor _, b := range []byte(s) { fmt.Printf("%08b ", b) }strconv.ParseUint(bits, 2, 8) per byte
Linux / macOSecho -n "Hi" | xxd -becho "48 69" | xxd -r -p (hex)

Frequently asked questions

How do I convert text to binary?

Look up the number of each character and write that number in base 2 with 8 digits. In ASCII and UTF-8, H is 72, which is 01001000, and i is 105, which is 01101001, so "Hi" is 01001000 01101001. Type any text in the box above and the binary appears as you type.

How do I convert binary to text?

Split the binary into groups of 8 bits (one byte each). Turn each group into a number by adding the place values 128, 64, 32, 16, 8, 4, 2 and 1 where the bit is 1, then look the number up in the ASCII table. 01000001 is 64 + 1 = 65, which is the letter A. Paste binary into the second box above to read it as text.

What is "Hello" in binary?

"Hello" is 01001000 01100101 01101100 01101100 01101111 in binary (ASCII or UTF-8). In hex it is 48 65 6C 6C 6F, and in decimal 72 101 108 108 111. Capital H (01001000) and small h (01101000) differ in only one bit.

What is "I love you" in binary?

"I love you" is 01001001 00100000 01101100 01101111 01110110 01100101 00100000 01111001 01101111 01110101. That is 10 bytes: 8 letters and 2 spaces (00100000). In hex it is 49 20 6C 6F 76 65 20 79 6F 75.

Why is one letter 8 bits?

Computers store text in bytes, and one byte is 8 bits. ASCII, the original code for English letters, digits and symbols, needs only 7 bits (128 characters), so the first bit of an ASCII byte is always 0. Some puzzles write 7-bit groups; this converter also reads those.

Why do é, Chinese characters and emoji give more bytes?

One byte can only hold 256 different values, but Unicode has more than 150,000 characters. UTF-8, the encoding used on almost every web page, keeps ASCII at 1 byte and uses 2 bytes for letters such as é, 3 bytes for most Chinese, Japanese and Korean characters and the euro sign, and 4 bytes for emoji. "é" is 11000011 10101001 in UTF-8.

What is the difference between ASCII, Unicode and UTF-8?

ASCII is a list of 128 characters with numbers 0 to 127. Unicode is the big list that gives a number (a code point, such as U+00E9 for é) to every character in every script; its first 128 numbers are the same as ASCII. UTF-8 and UTF-16 are ways to store those numbers as bytes. For plain English text, ASCII and UTF-8 give exactly the same binary.

More developer tools