Binary to Hexadecimal Converter

Convert binary numbers to hexadecimal (and back) using the standard 4-bit nibble method.

Convert 4-bit nibbles 0x / # prefix
Rate this calculator

Binary ↔ Hexadecimal

4-bit nibble grouping · step-by-step output

Instructions — Binary to Hexadecimal Converter

1

Choose direction

Binary → Hex starts with 0s and 1s and outputs hex digits 0-F. Hex → Binary does the reverse. The default 11010110 gives D6.

2

Type or paste your value

Spaces, commas, and underscores are ignored. For hex input, the 0x and # prefixes are stripped automatically. Quick-pick buttons load common values like FF, AA, and DEADBEEF.

3

Read the breakdown

Below the answer, each 4-bit nibble is shown with its hex digit and decimal value. Toggle uppercase A-F or lowercase a-f, and pick a prefix (0x for code, # for CSS colors).

Memorize four facts: 1000 = 8, 0100 = 4, 0010 = 2, 0001 = 1. Add those up and you have every nibble.
Color codes: Web colors use the # prefix and exactly six hex digits — two for each RGB channel.

Formulas

Hex is base 16. Each digit is worth 16 times the digit to its right. Because 16 = 2⁴, four binary bits map onto one hex digit cleanly with no division required.

Binary to hex (nibble method)
$$ \text{Hex digit} = \sum_{i=0}^{3} b_i \cdot 2^i $$
Group binary into 4-bit nibbles from the right, pad with leading zeros, convert each nibble to its hex digit 0-F.
Hex to binary
$$ \text{Nibble} = \text{hex digit value in 4 bits} $$
Each hex digit expands to exactly four binary bits. A becomes 1010, F becomes 1111. Concatenate and strip leading zeros.
Why four bits per digit
$$ 2^4 = 16 $$
A 4-bit field has 16 possible values (0000 through 1111). Hex has 16 digits (0-9, A-F). The match is exact, which is why the conversion is mechanical.
Worked example: 11010110
$$ 1101_2 = 13_{10} = D_{16} \\ 0110_2 = 6_{10} = 6_{16} $$
Split into 1101 and 0110, look up each nibble, concatenate. The answer is D6 (or 0xD6 in C, #D6 in shorthand CSS).
Decimal cross-check
$$ 11010110_2 = 214_{10} = D6_{16} $$
Convert to decimal first, then divide by 16 repeatedly. 214 ÷ 16 = 13 remainder 6. Reading remainders bottom-up gives D6.
One byte = two hex digits
$$ 11111111_2 = FF_{16} = 255_{10} $$
Every byte (8 bits) is two hex digits. This makes hex the standard for memory addresses, RGB colors, and machine-level data.

Reference

Nibble Lookup — 4-bit binary to hex
BinaryDecimalHex
000000
000111
001022
001133
010044
010155
011066
011177
100088
100199
101010A
101111B
110012C
110113D
111014E
111115F

Common byte values you will see in code

Bytes
HexBinaryDec
00000000000
0F0000111115
100001000016
7F01111111127
8010000000128
AA10101010170
FF11111111255
Colors (CSS)
HexColor
#000000Black
#FFFFFFWhite
#FF0000Red
#00FF00Green
#0000FFBlue
#FF5733Orange-red

Article — Binary to Hexadecimal Converter

Binary to Hexadecimal Conversion Explained

Binary to hexadecimal conversion turns a string of 0s and 1s into a shorter base-16 representation, where each hex digit (0-9, A-F) corresponds to exactly four binary bits. The byte 11010110 becomes D6 — eight characters shrink to two, with no precision lost. This works because 2⁴ equals 16, so the nibble (4-bit) grouping is mechanical and reversible.

Programmers reach for hex constantly: memory addresses, color codes, machine instructions, file signatures, and cryptographic keys all live in hex. Once you internalize the 16-entry nibble lookup table, conversion takes seconds rather than minutes.

What is binary to hex conversion?

Binary to hexadecimal is a numeral-system change, not an arithmetic operation. The value stays the same — 214 in decimal, 11010110 in binary, D6 in hex — only the representation differs. Hex is base 16, meaning each digit position is worth 16 times the position to its right.

The digit set for hex runs 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. The letters cover the values 10 through 15 because single digits run out at 9. This is the only quirk most people stumble on at first: A is ten, F is fifteen, and there is no G.

Did you know

IBM introduced the modern hex notation in 1964 with the IBM System/360 mainframe. Before that, some systems used the digits 0-9 then symbols like u, v, w, x, y, z. The A-F convention won because it survives plain-text serial terminals.

The nibble method for binary to hex

The standard algorithm is dead simple. Take your binary number, split it into 4-bit groups starting from the right, pad the leftmost group with zeros if it falls short, then convert each group to its single hex digit. The word nibble (four bits, half a byte) is the technical name for one of these groups.

Try 1011001011010110. Split from the right: 1011, 0010, 1101, 0110. Convert each: 1011 = B, 0010 = 2, 1101 = D, 0110 = 6. The answer is B2D6. Sixteen bits became four hex digits. No multiplication, no division, just lookup.

Nibble lookup — memorize the four anchors
1000 = 8 0100 = 4
0010 = 2 0001 = 1
1111 = F 1010 = A

Hex to binary the reverse way

The reverse is even easier. Each hex digit expands to exactly four binary bits. Write them out in order, strip any leading zeros, and you are done. The hex string DEADBEEF expands to 11011110 10101101 10111110 11101111 — a 32-bit constant that programmers use as a memory-poison sentinel because no real data looks like it.

One detail worth remembering: pad each hex digit to four bits. The digit 5 is 0101, not 101. Without the leading zero you lose alignment when concatenating multiple digits.

Why hex matters in computing

Hex is a compression trick. The byte is the universal unit of memory, and one byte (8 bits) packs into exactly two hex digits. A 32-bit integer fits in 8 hex digits, a 64-bit pointer in 16. Reading hex is roughly four times faster than reading the equivalent binary, with zero loss of information.

Almost every low-level tool — debuggers, hex editors, disassemblers, network packet captures — displays raw memory in hex. The convention is so deep that the Linux kernel, the Windows BSOD screen, and the macOS panic log all show error codes in hex without translation.

Did you know

Famous hex constants live in real code. 0xDEADBEEF marks freed memory in some debuggers, 0xCAFEBABE is the magic number at the start of every Java class file, and 0xFEEDFACE was used by the macOS Mach-O loader for 32-bit binaries.

Binary vs hex vs decimal at a glance

The three systems each have a job. Decimal is for humans counting in tens. Binary is for transistors flipping between two states. Hex is the practical compromise for humans reading raw machine data.

  • Binary = base 2, digits 0-1, native to hardware, verbose in print
  • Octal = base 8, digits 0-7, used for Unix file permissions (chmod 755)
  • Decimal = base 10, digits 0-9, the human default
  • Hexadecimal = base 16, digits 0-F, the programmer default
  • One byte = 8 binary bits = 3 decimal digits (max 255) = 2 hex digits (max FF)
  • One word (32-bit) = 32 bits = 10 decimal digits = 8 hex digits

Common hex uses in real code

The most visible hex in the wild is CSS color codes. #FF5733 packs three bytes: FF for red (255), 57 for green (87), 33 for blue (51). The hash mark plays the same role as the 0x prefix in C — it tells the parser the digits are hex, not decimal.

Memory addresses are next. A debugger reporting that a crash happened at 0x7FFC8A1B2030 is saying that location in virtual memory holds the offending instruction. The number is ugly in decimal (140,723,094,749,232) but readable in hex.

2
Binary
11111111
8 characters
16
Hexadecimal
FF
2 characters, same value

Common binary-to-hex mistakes

The first mistake is grouping from the left instead of the right. Always pad the leading edge. The binary 10110 looks like a 5-bit number, so pad to 8 bits (one nibble of zero) to get 00010110, which splits into 0001 and 0110, giving 16.

Watch for negative numbers

This calculator handles unsigned binary. If you have a negative number stored in two's complement, the conversion to hex still works, but you need to know the bit width. The 8-bit value -5 is 11111011 = FB. The 32-bit value -5 is FFFFFFFB. Same value, different hex representation.

The second mistake is treating hex letters as variable names. F is the number 15, not a variable. Mixing the letter O with the digit 0, or the letter I with the digit 1, also tripped up early hex assemblers — which is why hex stops at F instead of running through the whole alphabet.

Hex prefixes: 0x, #, and h

Different languages mark hex differently. C, C++, Java, JavaScript, Python, and Rust all use the 0x prefix. CSS and HTML use the # prefix for color codes. Assembly traditions vary: Intel syntax tacks h on the end (FFh), AT&T syntax uses $ at the front ($0xFF). Pascal used $ as well.

Tip

When pasting code into this converter, the 0x, 0X, and # prefixes are stripped automatically. So 0xDEADBEEF and DEADBEEF give the same binary expansion. Spaces and underscores in either input are ignored — useful when copying from documentation.

One final note: the convention of starting a hex literal with the digit 0 (so the parser sees a number, not an identifier) is why we write 0xFF and not just xFF. The lone x would be parsed as a variable named x in most languages.

FAQ

Group the binary digits into blocks of four starting from the right. Pad the leftmost block with zeros if needed. Convert each block to a single hex digit using the nibble table (1010 = A, 1111 = F, and so on). For example, 11010110 splits into 1101 and 0110, giving D6.
Hex is just compressed binary — every hex digit stands for exactly four bits — but it is four times shorter and far easier to read. 11111111 11111111 in binary becomes FFFF in hex. Memory addresses, RGB colors, and machine code are all easier to debug in hex.
The 0x prefix tells the compiler or reader that the following digits are hexadecimal. So 0x10 means 16 in decimal (not 10). C, C++, Java, JavaScript, and Python all use 0x. CSS uses # for the same purpose in color codes.
11111111 = FF = 255. This is the maximum value of one byte (8 bits) and the brightest value of any single RGB channel. Pure red in CSS is #FF0000, which is 255 red, 0 green, 0 blue.
Yes. The nibble method scales without limit because it processes the binary in 4-bit chunks. The only thing to watch is the leading pad: if your binary has 10 bits, pad to 12 (three nibbles) before converting.
DE AD BE EF = 11011110 10101101 10111110 11101111. This 32-bit hex constant is famously used as a sentinel value in debugging — easy to spot in a memory dump because no normal data looks like it.
Yes. FF and ff are identical values (255). Older C code tends to use uppercase, modern Python and JavaScript tend toward lowercase. Pick one and be consistent. CSS allows either but most style guides prefer lowercase.
A CSS color like #FF5733 packs three bytes: FF for red (255), 57 for green (87), 33 for blue (51). Each pair of hex digits is one RGB channel from 0 to 255. The shorthand #F53 expands to #FF5533 by doubling each digit.