Binary & Hex Converter
Convert text and numbers between binary, hexadecimal, decimal, and octal formats for programming and data analysis.
Related Tools
How to Use
- Enter Your Value — Type or paste a number in binary, octal, decimal, or hexadecimal format, or enter text to see its binary or hex representation.
- Choose a Mode and Input Base — Pick Number, Text to binary/hex, or binary/hex to Text mode. For numbers and bytes, choose the input base or leave it on Auto-detect.
- View All Representations — Click Convert (or press Ctrl+Enter) to see the value expressed in all four bases at once, then use Copy next to the one you need.
About the Binary & Hex Converter
The Binary & Hex Converter has three modes. Number converts a whole number between binary, octal, decimal and hexadecimal. Text → binary / hex bytes shows the UTF-8 bytes of any text in all four bases. Binary / hex bytes → text decodes a list of bytes back into readable text. Programmers use it to check bit masks, color values and byte dumps, students to practice base conversion, and anyone curious to see how many bytes an accented letter or emoji really takes.
How each mode works
- Number mode uses JavaScript's BigInt, so whole numbers of any length convert exactly, well past the 2^53 limit of ordinary JavaScript numbers. The prefixes 0b, 0o and 0x are recognized, spaces, commas and underscores used to group digits are ignored, and a minus sign is kept. The result lists all four bases and the number of bits.
- Auto-detect in Number mode reads 0s and 1s as binary when there are at least eight digits or they are typed in spaced groups (
1010 0110), other plain digits as decimal (so100and1,000stay decimal), and anything containing the letters A–F as hexadecimal. Octal is detected only with the 0o prefix, so choose Octal in the From menu for a bare value such as 377. - Text mode encodes your text as UTF-8 and lists each byte: binary padded to 8 digits, hex to 2, octal to 3, and decimal unpadded. ASCII characters take one byte, é takes two, € three, and most emoji four.
- Bytes mode accepts bytes separated by spaces or commas, with an optional 0x or \x prefix on hex bytes, or one unbroken run of binary (a multiple of 8 bits) or hex (an even number of digits). Decimal and octal bytes work when you pick them in From. Each byte must be 0–255, and the bytes must form valid UTF-8.
Worked examples
| Input | Mode | Result |
|---|---|---|
255 | Number | Binary 11111111, hex FF, octal 377, 8 bits |
0xDEADBEEF | Number | Decimal 3735928559, 32 bits |
-42 | Number | Binary -101010, hex -2A, octal -52 |
Hi | Text | 01001000 01101001 / hex 48 69 |
é | Text | 11000011 10101001 / hex C3 A9 |
😀 | Text | Hex F0 9F 98 80 (4 bytes) |
48 69 or 01001000 01101001 | Bytes | Hi |
Edge cases to watch
- Short binary values are ambiguous: on Auto-detect,
1010is read as the decimal number one thousand and ten. Type0b1010or set From to Binary when you mean binary. An eight-digit decimal made only of 0s and 1s, such as10000000, is read as binary — set From to Decimal for numbers like that. - In Bytes mode, binary bytes must be written as eight digits each (
01001000); short tokens such as10 11are read as hex bytes. A prefix counts only when the digits after it fit, so0BADis read as hexadecimal rather than as a binary prefix. - Negative numbers are shown with a minus sign, not in two's complement, and fractions or floating-point values are not converted.
1e3is not scientific notation here: it is read as the hex number 1E3 (483). - Bytes that are not valid UTF-8, such as
FF FEor a loneC3, produce an error rather than replacement characters. Bytes below 20 hex decode to control characters, which are invisible in the result.
When to use it
Hexadecimal is the usual shorthand for binary because each hex digit stands for exactly four bits, so a byte is always two hex digits. That is why CSS colors (#FF5733 is red 255, green 87, blue 51), Unicode code points (U+00E9), MAC addresses and memory dumps are written in hex. Text mode helps with encoding bugs: if é shows up as é, its two UTF-8 bytes C3 A9 were read as two separate Latin-1 characters. The Binary, Decimal, and Hexadecimal guide shows how to convert by hand, and the Base64 Encoder & Decoder covers the other common way of writing bytes as text.
All conversions run in your browser; nothing you enter is uploaded.
Frequently Asked Questions
What number bases does the converter support?
The tool supports four bases: binary (base-2), octal (base-8), decimal (base-10), and hexadecimal (base-16). You can convert in any direction between these four systems.
Can I convert text strings to binary or hexadecimal?
Yes. When you enter a text string, the converter encodes each character using its UTF-8 byte values and displays the binary and hexadecimal representations. This is useful for understanding how computers store text internally. The Binary / hex bytes to text mode reverses the process and decodes space-separated bytes back into readable text.
What is hexadecimal used for in programming?
Hexadecimal is widely used in programming for color codes (e.g., #FF5733), memory addresses, MAC addresses, and byte-level data inspection. Each hex digit represents exactly four binary bits, making it a compact way to express binary data.
How do I know if my input is valid for the selected base?
The tool validates your input against the base chosen in the From menu (or the base it auto-detects). Binary accepts only 0 and 1, octal accepts 0-7, decimal accepts 0-9, and hexadecimal accepts 0-9 and A-F. Prefixes such as 0b, 0o and 0x are recognised, spaces and underscores used for digit grouping are ignored, and an invalid character triggers an error message naming the problem.
Why is binary important in computing?
Computers operate using transistors that have two states: on and off. Binary (base-2) maps directly to this physical reality, with 1 representing on and 0 representing off. Every piece of data — text, images, audio — is ultimately stored and processed as binary.
Does the converter handle negative numbers or floating-point values?
Whole numbers of any size are converted exactly, including very large values beyond the usual 2^53 JavaScript limit. Negative numbers are shown with a minus sign (for example -1010 in binary). Two's-complement representation and IEEE 754 floating-point values are not supported.