Skip to content
Aarrange

Binary to Hex

Paste binary numbers, one per line; spaces between groups are fine. Get hex, with or without 0x. Nothing leaves your browser.

Also: All bases, Hex to Dec, Dec to Hex, Bin to Dec, Dec to Bin, Hex to Bin

0
Numbers
0
Max bits
0
Errors
Input
Tab types a tab. Press Escape, then Tab, to leave the editor.
Result
The result shows here as you type.Try , or .
On this page

About Binary to Hex

Updated

Binary to Hex writes long strings of bits as short hex numbers. Paste one, or a list of bytes from a packet dump, flags from a register, or homework. Each line is converted, and a line with a digit that is not 0 or 1 is marked at that digit.

Bits in groups, like 1010 0101 or 0b1111_0000, are read as one number. Turn on Prefix to get 0x in front for code. For the bytes of a file, use the Base64 Decode hex view.

The same tool, set up for other bases: Hex to Decimal, Decimal to Hex, Binary to Decimal, Decimal to Binary, Hex to Binary, Number Base Converter.

How to use it

  1. Paste binary numbers, one per line, or load a file. Commas, tabs and semicolons also split a line, so a column from a spreadsheet works.
  2. Check From and To, next to Convert. On a phone they are under More.
  3. Press Convert (Alt C). Results shows every number in the To base and in decimal, hex, binary and octal. Output shows only the answers, line for line, for Copy and Download.
  4. Open Steps to see the math for one number, the way you would do it on paper.
  5. Swap (Alt S) puts the answers in the editor and turns From and To around, so you can check the way back.
  6. In Options: Signed for two's complement, Groups for 1111 0000 or 4,294,967,295, Prefix for 0x, 0b or 0o, and how many digits a fraction gets.

How to convert binary to hex by hand

Group the bits in fours from the right, pad the first group with zeros, and write each group as one hex digit:

Binary to hex
Bits     11 1111 1010 1001
Groups 0011 1111 1010 1001
Hex       3    F    A    9

11111110101001 = 3FA9

Binary to hex chart

Binary to hex
Binary  Hex   Binary  Hex   Binary  Hex   Binary  Hex
 0000    0     0100    4     1000    8     1100    C
 0001    1     0101    5     1001    9     1101    D
 0010    2     0110    6     1010    A     1110    E
 0011    3     0111    7     1011    B     1111    F

Negative numbers and two's complement

With a minus sign in front, binary needs a width before it has hex digits. Set Signed to 8-bit and -101 (minus 5) becomes FB.

How two's complement works, with a table and the method by hand.

Exact for big numbers

Each group of 4 bits maps to one hex digit, so 64 ones give FFFFFFFFFFFFFFFF here. A converter that goes through JavaScript numbers rounds them first and gives 10000000000000000.

Why other converters round past 2^53.

Common errors

A digit that is not 0 or 1

Binary has only two digits. A 2 means the number is not binary, or a key was hit by mistake.

Invalid
10201
2 is not a binary digit. Binary uses only 0 and 1. Remove the 2,
or set From to base 3 or more.
Fixed
10001

The letter O for a zero

Typed by hand, a capital O and a zero look the same. The tool names the letter, so you know what to type.

Invalid
10O1
The letter O is not a digit. Type the digit 0 (zero) in its place.
Fixed
1001

Two numbers on one line

Bits are often grouped in fours, as in 1111 0000. When the groups are not the same size, the tool still reads one number, 1E3 in hex here, but marks the line, because it may be a list of bytes.

Warning
1111 000 11
Read as one number, 111100011. If these are separate numbers, put each
on its own line or split them with commas.
Fixed
1111, 000, 11

A number too big for its bits

With Signed set to a width, every number must fit in it. A ninth bit does not fit in a byte.

Invalid
100000000 (Signed: 8-bit)
100000000 does not fit in 8 bits. 8 bits hold up to 11111111 in binary.
Pick a wider Signed setting, or set it to Off.

Binary to hex in code and Excel

Binary to hex
JavaScript  parseInt("101101", 2).toString(16)        // "2d"
            BigInt("0b" + bits).toString(16)          // any length
Python      hex(int("101101", 2))                     # '0x2d'
            format(int("101101", 2), "X")             # '2D'
C           printf("%lX", strtol("101101", NULL, 2))  // 2D
Java        Integer.toHexString(Integer.parseInt("101101", 2))  // "2d"
Excel       =BIN2HEX("101101")                        → 2D
            =BIN2HEX("101101", 4)                     → 002D

BIN2HEX takes up to 10 bits, and the 10th bit is the sign: =BIN2HEX("1111111111") is FFFFFFFFFF. For more bits, split them in groups of 8 and convert each byte.

Binary to hex resources

Binary to hex FAQ

How do you convert binary to hex?

Split the bits into groups of 4, starting from the right. Add zeros in front of the first group if it is short. Then write each group as one hex digit: 0000 is 0, 1001 is 9, 1010 is A, 1111 is F.

For 101101: the groups are 0010 and 1101, so the hex is 2D.

What is 11111111 in hexadecimal?

11111111 is FF: two groups of 1111, and 1111 is F. In decimal it is 255.

Why group from the right?

The right end is the ones place, so the groups must line up with it. Grouped from the left, 101101 would split into 1011 and 01, and give the wrong answer. When the bits fill whole groups, both ways agree.

How do I convert a binary file to hex?

This tool converts numbers written in binary digits. For the bytes of a file, a hex dump is what you want: each byte becomes two hex digits. Drop the file on Base64 Decode. It turns the file into Base64, and its Hex view shows the bytes, 16 per line, with the readable characters at the right. It takes files up to 50 MB and shows the first 64 KB, all in your browser.

Can I convert binary with a point to hex?

Yes. Bits after the point group from the left, in fours: 101.1 is 0101.1000, which is 5.8 in hex. In decimal that is 5.5.

Are my numbers sent anywhere?

No. The numbers are converted in your browser, with JavaScript BigInt. Nothing is uploaded, and there are no ads or cookie walls. You can check this in your browser's network tab while you use it.