Binary / Hex Converter

Convert whole numbers between binary, octal, decimal, and hexadecimal: exact at any size, with the place-value working.

Details

Whole numbers only, decimal uses 0 to 9.

In binary (base 2)

1111 1111

255 in decimal is 255 in ordinary numbers

Octal377
Decimal255
HexadecimalFF

How many bits

8

Bytes (8 bits each)

1

Hex digits

2

Fits in

8-bit

DigitPlaceWorthAdds
210²100200
510¹1050
510⁰15

This converts numbers between binary, hexadecimal, decimal and octal in any direction.

It also shows how many bits and bytes the value needs, which is what matters when you are thinking about storage or data types.

Why computers use binary and hex

We count in decimal, base 10, because we have ten fingers. Computers count in binary, base 2, because a circuit is either on or off and there is no third state.

Binary works but is unreadable for humans. The number 255 becomes 11111111, and real values run far longer than that.

Hexadecimal, base 16, exists to fix exactly that. It is not a separate system so much as shorthand for binary: one hex digit is exactly four bits, so any binary number collapses to a quarter of the length with no arithmetic at all.

255 in three bases
255decimal
=
1111 1111binary, 8 bits
=
FFhex, 2 digits

Each group of four bits becomes one hex digit: 1111 is F. That is the whole relationship, and it is why hex is grouped in fours.

What to enter

Convert from / to
Binary, octal, decimal or hexadecimal, in any combination.
Your number
Only valid digits for the base you chose. Binary takes 0 and 1 only; hex takes 0-9 and A-F.
How many bits
Sets the width for the binary view, which matters when working with fixed-size data types.

The bases, and where each shows up

Binary (base 2)
Digits 0 and 1. How hardware actually stores everything.
Decimal (base 10)
Digits 0-9. What people use.
Hexadecimal (base 16)
Digits 0-9 then A-F, where A is 10 and F is 15. Used for colours, memory addresses and byte values.
Octal (base 8)
Digits 0-7. Mostly seen now in Unix file permissions, where 755 is three groups of three bits.
One byte
8 bits, holding 0 to 255, which is exactly two hex digits: 00 to FF.

What this assumes

Whole non-negative numbers. Negative values in real systems use two's complement, which depends on the bit width.

How to calculate between binary, hex and decimal

Binary to hex needs no arithmetic at all, just grouping. The others need a little division.

1 hex digit = 4 bits 1 byte = 8 bits = 2 hex digits
4 bits
Holds 0 to 15, which is exactly one hex digit's range
  1. Binary to hex: group in fours. Split the binary from the right into groups of four and convert each. 1111 1111 becomes F F.

  2. Hex to binary: expand each digit. Replace every hex digit with its four bits. Nothing else is needed.

  3. To decimal: use place values. Each binary place is double the last: 128, 64, 32, 16, 8, 4, 2, 1. Add the ones that are switched on.

  4. From decimal: divide and keep remainders. Divide repeatedly by the target base, then read the remainders bottom to top.

See a worked example: converting 255 by hand
Number
255 in decimal

Place values in 8 bits are 128, 64, 32, 16, 8, 4, 2, 1. They add to exactly 255, so every bit is on: 11111111.

Group into fours: 1111 and 1111.

Each 1111 is 15, which is F in hex. So 255 is FF.

This is the largest value one byte can hold, which is why colour codes run 00 to FF per channel.

255 = 11111111 = FF

Frequently asked questions

Problems people actually run into

Grouping binary from the left instead of the right

Binary must be grouped into fours starting from the right, exactly as you would read place values. Grouping from the left produces a completely different hex value.

If the number of bits is not a multiple of four, pad the left with zeros. 110 becomes 0110, which is 6, not 12.

Reading hex as if it were decimal

The value 10 in hex is sixteen, not ten. A memory address of 0x20 is 32, and a limit of 0x64 is 100.

This is why hex is usually written with a 0x prefix or a # sign. When you see either, stop reading the digits as ordinary numbers.

Results are estimates for general information only and are not professional financial, medical, or legal advice. Read our full disclaimer.

Last updated: September 4, 2026