Encoding Tools
Text to Binary / Hex Converter
Convert text to binary or hexadecimal bytes and back, using UTF-8.
Input stays in this browser while you use the tool.
About this tool
The Text to Binary / Hex Converter shows the bytes behind a piece of text, and turns bytes back into text. A computer does not store letters. It stores numbers, and a character encoding decides which number stands for which character. This tool takes your text, encodes it as UTF-8 and writes the bytes in binary (ones and zeros) or in hexadecimal (base 16). It can also work in the other direction: paste bytes, and it shows the text that they spell.
Take the word Hello. Its five letters are the five bytes 48 65 6c 6c 6f in hexadecimal, which are 01001000 01100101 01101100 01101100 01101111 in binary and 72 101 108 108 111 in decimal. Every byte has 8 bits, so it is written as exactly 8 binary digits or as 2 hexadecimal digits. Hexadecimal is popular because it is compact: one byte is always two characters.
The number of bytes is not always the number of characters. In UTF-8, the encoding of most of the web, plain English letters take one byte, accented letters and many other alphabets take two, symbols such as the euro sign take three and emoji take four. The word Café has 4 characters and 5 bytes.
Converting text to binary or hex is a way of writing it, not a way of hiding it. Anyone can convert it back, and there is no key. The conversion runs in your browser, so your text is processed on your own device and is not sent to the BitToolsKit server.
Use cases
- Learn how text is stored. See that a capital A is 65 (
41in hex), that a space is 32 (20), and that a lowercase letter differs from its capital by a single bit. - Debug character encoding problems. If a name shows up as
Caféor as a question mark in a box, look at the bytes to find out which encoding was really used. - Find invisible characters. A trailing line break is
0a, a Windows line break is0d 0a, and a tab is09. The bytes show what the eye cannot. - Inspect data in protocols and file formats. Hex is the usual way to read network packets, file headers and binary fields in documentation.
- Prepare byte values for code. Copy hex bytes into a byte array in C, Rust, Go or JavaScript, or check that your code produces the bytes that you expect.
- Check what a hash or an encoding is really working on. A hash such as SHA-256 is calculated from the bytes of the text, so a different encoding or a hidden line break gives a different hash.
- Decode a message written in binary or hex. Puzzles, school exercises and capture-the-flag challenges often hide text this way.
- Compare the size of strings. A database column, an API or a message limit may be counted in bytes, and the byte count of text with accents or emoji is higher than its character count.
How to use
- Choose the direction: convert text to binary or hex, or convert binary or hex back to text, if the tool shows that choice. If it offers an output format, select binary, hexadecimal or decimal.
- Type or paste your input into the Input box. To encode, paste the text. To decode, paste bytes written as pairs of hexadecimal digits, such as
48 65 6c 6c 6f, or as groups of 8 binary digits, such as01001000 01101001. - Click Run tool.
- Read the result in the Output box. When you encode, each byte appears as 8 binary digits or as 2 hexadecimal digits. When you decode, you get the text.
- If a message appears when you decode, or the text contains strange characters, check the input against the common errors below.
- Click Copy output to copy the result, Download to save it as a file, or Clear to start again.
When you decode, remove anything that is not a byte: a 0x prefix, a \x prefix and commas. Hexadecimal digits can be written in lower or upper case, but every byte needs two digits and every binary byte needs eight. To go from hex to another notation, use the Base64 Encoder / Decoder for Base64, or the HTML Entity Encoder / Decoder for HTML entities.
Examples
Example 1: A word in binary, hexadecimal and decimal
Input (text): Hello
What a converter produces: Hex: 48 65 6c 6c 6f Binary: 01001000 01100101 01101100 01101100 01101111 Decimal: 72 101 108 108 111 Five characters become five bytes.
Example 2: Capital and lowercase letters
Input (text): A a
What a converter produces: A = 41 = 01000001 space = 20 = 00100000 a = 61 = 01100001 The two letters differ in a single bit, the value 32 (hex 20).
Example 3: A letter with an accent
Input (text): Café
What a converter produces (UTF-8): 43 61 66 c3 a9 The text has 4 characters but 5 bytes, because é takes the two bytes c3 a9.
Example 4: A symbol and an emoji
Input (text): € 😀
What a converter produces (UTF-8): € = e2 82 ac (3 bytes) space = 20 😀 = f0 9f 98 80 (4 bytes, binary 11110000 10011111 10011000 10000000)
Example 5: An Urdu word
Input (text): اردو
What a converter produces (UTF-8): d8 a7 d8 b1 d8 af d9 88 Four letters take eight bytes, two for each letter.
Example 6: Hexadecimal back to text
Input (hex): 48 65 6c 6c 6f C3 A9
What a converter produces: Hello é The bytes c3 a9 are read together as the single letter é.
Example 7: Binary back to text
Input (binary): 01001000 01101001
What a converter produces: Hi
Example 8: Spaces, tabs and line breaks
Input (text): One space, one tab and a line break
The invisible characters in hex: space = 20 tab = 09 line break (Linux and macOS) = 0a line break (Windows) = 0d 0a A text copied from a Windows file can end with the two bytes 0d 0a.
Example 9: Bytes that are not valid UTF-8
Input (hex): ff
What a decoder produces: The byte ff never occurs in valid UTF-8. A decoder shows the replacement character � or reports an error. A single c3 on its own also fails, because that byte announces a two-byte letter whose second byte is missing.
Example 10: The same letter in two encodings
Input (text): é
In UTF-8: c3 a9 In Latin-1 (ISO-8859-1): e9 If the UTF-8 bytes of Café are read as Latin-1, the result is Café. This mix-up is the usual cause of garbled accents.
Common errors
The hexadecimal input has an odd number of digits
Every byte is written with exactly two hexadecimal digits, so the input must have an even number of digits. A single digit such as 6 must be written 06. Check for a missing or extra character, especially at the start or the end.
A 0x prefix, a backslash-x prefix or commas are in the input
Many tools and programming languages write bytes as 0x48 or \x48. A decoder usually expects plain pairs of digits such as 48, separated by spaces or not separated at all. Remove the prefixes and the commas.
The binary input is not made of full bytes
Each byte needs exactly 8 binary digits, with leading zeros. The letter H is 01001000. If you write 1001000 or cut a group short, the bits shift and the result is wrong. The total number of binary digits must be a multiple of 8.
A binary group has more than 8 digits
A single byte can hold values from 0 to 255, which is 8 binary digits. A group such as 101001000 is the number 328 and does not fit into one byte. Split the input into groups of 8.
The output has more bytes than the text has characters
That is normal in UTF-8. Plain English letters take one byte, accented letters and many other alphabets take two, symbols such as the euro sign take three and emoji take four. Count bytes when a limit is measured in bytes.
The decoded text shows � or strange symbols
The bytes are not valid UTF-8, or they were written in another encoding. A lone e9 is the letter é in Latin-1, but it is not a complete letter in UTF-8. Find out which encoding the data uses, and make sure no byte is missing or changed.
Accented letters look like Café after decoding
Text that was written in UTF-8 was read as Latin-1 or Windows-1252, or the other way round. Each accented letter becomes two odd characters. Read the data with the same encoding that was used to write it.
The hexadecimal output is full of 00 bytes, such as 48 00 69 00
This is UTF-16, which uses two bytes for each of these letters, with the zero byte before or after the letter depending on the byte order. This tool uses UTF-8, where Hi is 48 69. Check which encoding your other system uses.
A line break or a space changes the result
A trailing line break adds the byte 0a, or 0d 0a on Windows, and a trailing space adds 20. Texts that look identical can have different bytes, and different hashes. Remove the extra characters or compare the bytes.
A byte order mark appears at the start of the text
Some editors put the bytes ef bb bf at the start of a UTF-8 file. They are invisible in most editors but part of the data. Remove them if your program does not expect them.
Frequently asked questions
How is text stored as binary?
Each character has a number in a character encoding, and that number is stored as one or more bytes of 8 bits each. In UTF-8, the letter H is the number 72, which is the byte 01001000.
What is the difference between binary and hexadecimal?
They are two ways of writing the same bytes. Binary uses the digits 0 and 1, so a byte has 8 digits. Hexadecimal uses the digits 0 to 9 and the letters a to f, so a byte has exactly 2 characters. Hex is shorter and easier to read.
What is the difference between ASCII and UTF-8?
ASCII defines 128 characters, such as the English letters, digits and punctuation, in the values 0 to 127. UTF-8 is an encoding of the whole Unicode character set. It writes the ASCII characters with exactly the same single byte, which is why plain English text is identical in both.
Why does the letter é take two bytes?
UTF-8 uses one byte for the first 128 characters and more bytes for the rest. The letter é has the Unicode number 233, which is above 127, so UTF-8 writes it as the two bytes c3 a9.
How many bytes does an emoji have?
Most emoji take four bytes in UTF-8. For example, the grinning face is f0 9f 98 80. In some languages, such as JavaScript, a string with one emoji reports a length of 2, because strings count 16-bit units and not characters.
What is the difference between characters and bytes?
A character is a letter, a digit or a symbol as a person sees it. A byte is a unit of storage. In UTF-8, one character takes between one and four bytes. The text Café has 4 characters and 5 bytes.
Is converting text to binary a kind of encryption?
No. It only changes how the text is written, and anyone can convert it back without a key. Do not use it to protect passwords or private data.
How is this related to Base64?
Both write bytes as text. Hexadecimal uses two characters for each byte, and Base64 packs three bytes into four characters, so Base64 is shorter. The word Hello is 48 65 6c 6c 6f in hex and SGVsbG8= in Base64.
Does the tool work with Urdu, Arabic and other alphabets?
Yes, if the tool encodes text as UTF-8. Each Urdu or Arabic letter usually takes two bytes. The word اردو has 4 letters and 8 bytes.
Is my text uploaded to a server?
No. The tool runs in your browser and works on your device. As a general habit, avoid pasting passwords, API keys or private tokens into any online tool.