OtherCalculators

Binary to Hex Converter

Enter a binary number to see it in hexadecimal, with the bits split into groups of four and each group's hex digit worked out in a table.

It works the other way too: type hex and the binary appears, exact for numbers of any length, with decimal and octal alongside.

Last updated: · Reviewed by Shakeel Alvi, OtherCalculators

Calculator mode

Type in either field

Spaces and the prefixes 0b and 0x are fine. Binary is padded on the left to whole groups of four, so every group is one hex digit.

Hex letters

10110110₂ in hex

B6

Decimal
182
Octal
266

Nibble by nibble

Split the bits into groups of four from the right. Each group is worth 8, 4, 2 and 1, and its total from 0 to 15 is one hex digit, 0–9 then A–F.

Each 4-bit group with its place values and hex digit
Bits8 + 4 + 2 + 1ValueHex
10118 + 2 + 111B
01104 + 266

Exact at any size

Whole numbers are worked digit by digit, so 64-bit values and beyond never round off after 15 or 16 digits. Floating-point mode prints the exact value the bits store.

Runs in your browser

What you enter is worked out on this page and is not sent anywhere. Copy the address to share a conversion.

Binary to HexHex to BinaryNibbles4 Bits = 1 DigitAny Length

Quick answer

To convert binary to hex, split the bits into groups of four starting from the right, padding the leftmost group with zeros, then replace each group with one hex digit: 0000 is 0, 1001 is 9, 1010 is A and 1111 is F. So 10110110 becomes 1011 0110, which is B6 in hex.
Guide

How the binary to hex converter works

Type bits into the Binary field and the hex value appears in the result card as you type, with the decimal and octal values beneath it. The nibble panel pads the bits on the left to a whole number of four-bit groups, draws them as a grid numbered from bit 0 on the right, and lists every group with its 8 + 4 + 2 + 1 sum and the hex digit it becomes.

Typing in the Hex field runs the same table in reverse. Because the converter uses whole-number arithmetic with no rounding, a 128-bit address or a 64-character hash converts digit for digit. For decimal or any base from 2 to 36, use the binary converter.

How the maths works

The nibble rule

16 = 2⁴, so 1 hex digit = 4 bits
Nibble value = 8·b₃ + 4·b₂ + 2·b₁ + 1·b₀
Values 10–15 are written A–F

Example: 1101 = 8 + 4 + 0 + 1 = 13, which is the hex digit D.

Worked example

Worked examples

Example 1 — a length that is not a multiple of four

Binary:
1011101
  1. Group from the right: 101 1101
  2. Pad the left group: 0101 1101
  3. 0101 = 4 + 1, 1101 = 8 + 4 + 1: 5, 13

Hex: 5D

Check: 5 × 16 + 13 = 93, and 1011101 is 64 + 16 + 8 + 4 + 1 = 93.

Example 2 — hex back to binary

Hex:
2F8
  1. 2: 0010
  2. F (15): 1111
  3. 8: 1000

Binary: 1011111000

The two leading zeros from the first group are dropped.

Reference data

The 16 nibbles: binary, hex and decimal

Every 4-bit pattern with its hexadecimal digit and decimal value
BinaryHexDecimal
000000
000111
001022
001133
010044
010155
011066
011177
100088
100199
1010A10
1011B11
1100C12
1101D13
1110E14
1111F15
Source: OtherCalculators — computed with the converter's own integer engine — hex digits A–F stand for ten to fifteen

Key facts

  • One hexadecimal digit stands for exactly four binary digits, because 16 is 2 to the power 4.
  • Binary converts to hex by splitting the bits into groups of four from the right and replacing each group with one hex digit.
  • A byte is 8 bits, so it is always written as two hex digits, from 00 to FF.
  • The 4-bit pattern 1111 is the hex digit F, which is 15 in decimal.
When you need this

Where you meet binary and hex together

Hex is how people read binary without counting thirty-two 0s and 1s. Programmers see it in memory dumps, colour codes such as #FF8800 (one byte each for red, green and blue), bit masks like 0xF0, and file signatures. Network engineers read MAC and IPv6 addresses in hex, and students meet it in computer science courses — binary and hexadecimal, and converting between them, are part of England's GCSE computer science content (source: DfE subject content). When the bits are meant as characters rather than a number, the binary to text converter decodes them instead.

Tips

Common binary to hex mistakes

  • Grouping from the left. 1011101 grouped as 1011 101 gives B and 5 — wrong. Group from the right: 101 1101 is 5D.
  • Writing 10 instead of A. A nibble worth ten to fifteen is one digit, A to F. Writing 1010 as “10” adds a digit and changes the value.
  • Dropping zeros inside the number. Leading zeros can go, but 0000 in the middle of a number is the digit 0 and must stay.
  • Mixing up prefixes. In code 0x10 is sixteen and 0b10 is two; a bare 10 is ten.
FAQ

Frequently Asked Questions

What is 11111111 in hex?

11111111 is FF in hex. Split it into 1111 and 1111; each group is 8 + 4 + 2 + 1 = 15, which is the hex digit F. It is also 255 in decimal, the largest value one byte can hold.

How do you convert hex to binary?

Replace each hex digit with its 4-bit pattern from the nibble table and join them. 3F becomes 0011 1111, and 7A2 becomes 0111 1010 0010. Leading zeros on the far left can be dropped.

Why group binary digits from the right?

The rightmost bit is always the 1s place, so groups counted from the right line up with hex places: the first four bits are the 16⁰ digit, the next four the 16¹ digit, and so on. Grouping from the left only works when the length is already a multiple of four.

Why does one hex digit equal exactly four bits?

Because 16 is 2⁴. Four bits can make 2 × 2 × 2 × 2 = 16 patterns, from 0000 to 1111, and hexadecimal has exactly 16 digits, 0–9 and A–F. That one-to-one match is why programmers use hex as shorthand for binary.

How many hex digits is a byte?

Two. A byte is 8 bits, which is two nibbles, so every byte is written as two hex digits from 00 to FF. A 32-bit value takes 8 hex digits and a 64-bit value takes 16.

What does the 0x in front of a hex number mean?

0x is the prefix programming languages such as C, Java and JavaScript use to mark a number as hexadecimal, so 0x1F means hex 1F (31), not a decimal number. Binary literals use 0b in the same way. This converter accepts both prefixes as typed.

Keep going

Notes & Assumptions

  • Binary and hex input is read as a whole number, exactly, up to 4,096 characters long.
  • A minus sign is kept as a sign. A negative number stored in a computer is a two's complement pattern, which the twos complement calculator produces.
  • Binary fractions such as 0.101 are not converted here.

This tool is for education and general calculation. Check values used in production code against your platform's documentation.