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
How many bits
8
Bytes (8 bits each)
1
Hex digits
2
Fits in
8-bit
| Digit | Place | Worth | Adds |
|---|---|---|---|
| 2 | 10² | 100 | 200 |
| 5 | 10¹ | 10 | 50 |
| 5 | 10⁰ | 1 | 5 |
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.
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.
- 4 bits
- Holds 0 to 15, which is exactly one hex digit's range
Binary to hex: group in fours. Split the binary from the right into groups of four and convert each. 1111 1111 becomes F F.
Hex to binary: expand each digit. Replace every hex digit with its four bits. Nothing else is needed.
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.
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
Because hex is compact and converts to binary with no arithmetic. One hex digit is exactly four bits, so a 32-bit value takes 8 hex digits instead of 32 ones and zeros.
It is far easier to read, transcribe and spot errors in. A memory address as hex is manageable; the same address in binary is not.
Base 16 needs sixteen digits, and we only have ten symbols, so letters fill the gap. A = 10, B = 11, C = 12, D = 13, E = 14, F = 15.
So FF is 15 sixteens plus 15, which is 255. Case does not matter: ff and FF are identical.
A code like #FF5733 is three bytes: FF red, 57 green, 33 blue. Each runs from 00 (none) to FF (maximum), giving 256 levels per channel.
That is 256³, or about 16.8 million colours. #FFFFFF is white and #000000 is black.
256, from 0 to 255. Eight bits, each with two states, gives 2⁸ = 256 combinations.
This is why so many limits in computing are 255: it is the largest number a single byte can hold.
Mostly Unix file permissions. `chmod 755` sets three groups of three bits: read, write and execute for owner, group and others.
7 is 111, meaning all three permissions, and 5 is 101, meaning read and execute but not write. Octal survives there because three bits map neatly to one digit.
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