Format Code Now
/

Binary to Hex Converter

CU-08

Paste binary numbers, one per line, and get hexadecimal back. The second button converts hex to binary. Each digit is mapped on its own, so leading zeros survive.

Runs in your browser. Nothing is uploaded.

Numbers (one per line)

Result

How to use it

  1. Paste one binary number per line. Spaces and underscores inside a number are ignored.
  2. Press Binary to hex. Use Hex to binary for the reverse direction.
  3. Pick uppercase or lowercase hex, and tick Add a prefix if you want 0x or 0b in front.
  4. Tick Trim leading zeros to drop them, or group binary results in 4 or 8 digits.
  5. Copy the result or download it as a .txt file.

How the conversion works

Four binary digits make one hex digit, so the tool pads your number on the left to a multiple of four bits and swaps each group for its hex digit. 1111 becomes F and 10101011 becomes AB. Because the mapping is digit for digit, a number such as 00001111 becomes 0F rather than F. That matters when you are reading a bit mask, a byte dump or a register value where the width carries meaning. If you only want the value, tick Trim leading zeros.

What it accepts and what it does not

A line may start with a minus sign, and a 0b prefix is accepted on binary input. Spaces and underscores inside a number are removed, so 1010 1011 reads as one number. Only whole numbers are handled. There is no fraction part, no two's complement and no fixed word size, so a negative number is shown with a minus sign and not as a bit pattern. Each line is converted on its own, and an error names the line and the character that was not allowed.

Error messages and what to do

MessageWhat it meansFix
"12" is not a binary number: "2" is not allowed (use 0-1).The line contains a digit that is not 0 or 1.Remove or correct that digit. Binary uses only 0 and 1.
"0b" has no binary digits.The line holds only a prefix or only spaces and underscores.Add the binary digits after the prefix.

Questions people ask

How do I convert binary to hex?

Split the binary number into groups of four digits from the right, then replace each group with its hex digit: 1010 is A and 1111 is F. This tool does that for every line you paste and keeps any leading zeros unless you ask it to trim them.

How do I convert hex to binary?

Replace each hex digit with its four-digit binary value: A is 1010, F is 1111 and 3 is 0011. Press Hex to binary and the tool does this for each line. Tick Group digits to show the result in groups of four or eight.

Why does the hex result keep leading zeros?

Each binary digit group is converted as written, so 00001111 gives 0F. That keeps the byte width visible. If you want the shortest form, tick Trim leading zeros and the result becomes F.

Can it convert a very long binary number?

Yes. The conversion works on the digits, not on a floating point value, so a 64-bit or longer number is not rounded. The only limit is what your browser can hold in the box.

Does it handle negative binary numbers or two's complement?

A leading minus sign is carried over to the result, so -1010 gives -A. It does not interpret a bit pattern as two's complement, because that needs a fixed width. Write the bit pattern as a plain positive number to convert it.

About this tool

Converts whole binary numbers to hexadecimal, and the second button goes the other way. Each digit is converted on its own (one hex digit is 4 bits, one octal digit is 3 bits), so leading zeros you type are kept: 0F becomes 00001111. Tick "Trim leading zeros" to drop them. Spaces and underscores inside a number are ignored, a leading minus sign is carried over, and a 0x, 0b or 0o prefix is accepted. Only whole numbers are handled; there is no fraction part and no two's complement. Each line is converted on its own, with no size limit other than your browser's.

Format Code Now: free, no ads, no accounts. Your input stays in your browser.