FormatterHQ

Binary to Hexadecimal Converter

Shrink long binary strings into compact hexadecimal. Every four bits become one hex digit, with support for fractions, 0b prefixes and upper or lower case output.

Loading tool…
Ready.

How to use the Binary to Hexadecimal Converter

  1. Type or paste a binary number in the Binary field; spaces between groups are ignored.
  2. Tick or clear Uppercase letters to choose the case of the digits A–F.
  3. Read the hexadecimal result in the Hexadecimal field and copy it.

Binary to hex: four bits per digit

This binary to hex converter packs long runs of 0s and 1s into short hexadecimal strings. Since 16 = 2^4, the conversion needs no arithmetic at all: every group of four bits, called a nibble, maps directly to one hex digit.

The nibble table

BitsHexBitsHex
0000010008
0001110019
001021010A
001131011B
010041100C
010151101D
011061110E
011171111F

Worked example

Start at the right-hand end and split the bits into groups of four, padding the leftmost group with zeros if needed.

110101111
→ 1 1010 1111
→ 0001 1010 1111
→ 1    A    F      = 1AF

For a fraction, group outward from the binary point: to the left as usual, and to the right padding the last group with trailing zeros. 101.101 becomes 0101 . 1010, which is 5.A.

Example output

Input        Output
1010         A
11111111     FF
100000000    100
10110011     B3
101.101      5.A
0b10110      16

Options and input tips

  • Letters: choose A–F or a–f. Lower case is common in hashes and CSS; upper case is common in datasheets.
  • Grouped input: spaces and underscores are ignored. Pasting 1101 0110 is therefore read as 11010110 and returns D6, and it works the same when the groups are not exactly four bits long. The field holds one number at a time.
  • Prefixes and length: a leading 0b is accepted, and there is no length limit.

Common slips

  • Grouping from the left. 110101111 grouped as 1101 0111 1 gives nonsense; always start from the right-hand end.
  • Confusing B (1011) with D (1101), or 6 (0110) with 9 (1001). The table above is worth keeping nearby until the patterns become automatic.

When hex beats binary

A 32-bit value is 32 characters in binary but only 8 in hex, and a byte is always exactly two hex digits. That is why masks, register values, checksums and machine code are almost always written in hex, even though the hardware thinks in bits.

For the reverse direction, use hex to binary. If you would rather group bits in threes, binary to octal does that, and binary to decimal gives the ordinary numeric value.

Binary to hex in code and spreadsheets

  • Python: format(int('110101111', 2), 'X') returns '1AF', and hex() gives '0x1af'. Python integers have no size limit.
  • JavaScript: parseInt('110101111', 2).toString(16) returns '1af', but it is only exact up to 53 bits. For longer strings use BigInt('0b' + bits).toString(16).
  • C and C++: binary literals such as 0b110101111 are standard since C++14 and C23; print them with %X.
  • Excel and Google Sheets: =BIN2HEX("11111111") returns FF. The input may have at most 10 bits, so split longer values into nibbles or use this converter.

The converter is handy when those limits get in the way: it accepts strings of any length, keeps fractions and shows the octal and decimal forms of the same value next to the hex result.

Frequently asked questions

Why does each hex digit equal four bits?
Four bits can hold 2^4 = 16 different patterns, and hexadecimal has exactly 16 digits. The mapping is one to one, so conversion is just a table lookup.
What if the number of bits is not a multiple of four?
Pad the leftmost group with zeros. 110101111 has nine bits, so it becomes 0001 1010 1111, which is 1AF. The converter does this automatically.
How do I write the result as a code literal?
Add the prefix your language uses, such as 0xB3 in C, Java, JavaScript or Python. The converter outputs just the digits so you can choose the prefix.
Can I convert text into hexadecimal here?
No, this tool converts binary numbers. To turn characters into their hex byte values, use a string to hex tool, which encodes the text first.

Last updated October 3, 2026

Related tools