Binary, Decimal, Hex & Octal Converter

Convert whole numbers between binary, decimal, hex, octal and any base.

Whole numbers of any size. A minus sign, spaces and 0x / 0b prefixes are fine.

Group digits

255 in decimal (base 10) =

1111 1111

binary (base 2)

255 in decimal is 11111111 in binary.

Binary (base 2)
1111 1111
Octal (base 8)
377
Decimal (base 10)
255
Hexadecimal (base 16)
FF
Bit length
8 bits

Fix the highlighted field to update the result.

Show the working

Repeated division (from decimal)

Divide by 2 until the quotient is 0. Read the remainders from the last row up to the first: 11111111.

Division steps
DivisionQuotientRemainder
255 ÷ 21271
127 ÷ 2631
63 ÷ 2311
31 ÷ 2151
15 ÷ 271
7 ÷ 231
3 ÷ 211
1 ÷ 201

How to use

  1. Type a whole number, such as 255, 1010 or FF. A minus sign, spaces and 0x / 0b prefixes are fine.
  2. Choose the base it is written in (from) and the base you want (to).
  3. Read the answer, plus binary, octal, decimal and hex all at once. Open Show the working for every step.

How base conversion works

To decimal: place values. Each digit is multiplied by a power of the base, counting from 0 on the right, and the results are added:

1011 in binary = 1×2³ + 0×2² + 1×2¹ + 1×2⁰ = 8 + 0 + 2 + 1 = 11

From decimal: repeated division. Divide by the new base, write down the remainder, and repeat with the quotient until it reaches 0. The remainders, read from the last to the first, are the new digits.

Hex and binary shortcut: each hex digit is exactly 4 binary digits, because 16 = 2⁴. So 9C is 1001 1100.

Examples

156 to binary, dividing by 2:

Division Quotient Remainder
156 ÷ 2 78 0
78 ÷ 2 39 0
39 ÷ 2 19 1
19 ÷ 2 9 1
9 ÷ 2 4 1
4 ÷ 2 2 0
2 ÷ 2 1 0
1 ÷ 2 0 1

Reading the remainders from the bottom up gives 10011100.

9C (hex) to decimal: 9×16¹ + C×16⁰ = 144 + 12 = 156, because C is 12.

Common values

Decimal Binary Octal Hex
0 0 0 0
1 1 1 1
2 10 2 2
7 111 7 7
8 1000 10 8
10 1010 12 A
15 1111 17 F
16 10000 20 10
100 1100100 144 64
255 11111111 377 FF
256 100000000 400 100
1,000 1111101000 1750 3E8
1,024 10000000000 2000 400
65,535 1111111111111111 177777 FFFF
Large and negative numbers
  • Any size, exactly: ordinary JavaScript numbers can’t hold every whole number above 9,007,199,254,740,991 (2⁵³ − 1). This converter uses exact whole-number arithmetic (BigInt), so 2⁶⁴ − 1 is exactly FFFFFFFFFFFFFFFF.
  • Negatives keep a minus sign, like −1010. Computers often store them as two’s complement, which depends on the bit width, so it is not shown here.
  • Bases up to 36 use the letters A to Z for the digits 10 to 35.

Comparing two values, such as a file size before and after compression? The percentage calculator gives the percentage change.

Frequently asked questions

How do I convert binary to decimal?

Multiply each digit by its place value (1, 2, 4, 8 and so on from the right) and add the results. For example, 1011 = 8 + 0 + 2 + 1 = 11.

How do I convert decimal to binary?

Divide by 2 again and again, writing down each remainder. Read the remainders from the last one to the first: 100 becomes 1100100.

What is 255 in hex and binary?

255 is FF in hexadecimal and 11111111 in binary. It is the largest number that fits in one byte (8 bits).

How do I convert hex to binary?

Swap each hex digit for its 4-bit group, because 16 = 2⁴. For example, 9C becomes 1001 1100.

Why do hex numbers contain letters?

Base 16 needs 16 digit symbols, so A to F stand for 10 to 15. Higher bases continue the alphabet up to Z, which is 35 in base 36.

How are negative numbers shown?

With a minus sign, like −1010. Computers often store negatives as two’s complement, which depends on the bit width, so this converter keeps the sign instead.