Number Converter: Binary, Decimal, Hex and Octal

Pick the base you are starting from and type a number. You get the binary, decimal, hex and octal values at once, and the working for any of them underneath.

Convert from

Decimal numbers use the digits 0 to 9. Negative numbers keep their minus sign.

Decimal (base 10)
-
Binary (base 2)
-
Hex (base 16)
-
Octal (base 8)
-

Worked example: 2024 in binary and hex

To go from decimal to another base, divide by the base repeatedly and read the remainders from the bottom up. Going from binary to hex is quicker: group the bits in fours from the right and swap each group for one hex digit.

2024 in decimal is 11111101000 in binary

Decimal to binary: divide by 2 and keep the remainders

Divide by 2 until the quotient is 0. The remainders, read from the bottom up, are the binary digits.

NumberDivisionQuotientRemainder
2,0242,024 ÷ 21,0120
1,0121,012 ÷ 25060
506506 ÷ 22530
253253 ÷ 21261
126126 ÷ 2630
6363 ÷ 2311
3131 ÷ 2151
1515 ÷ 271
77 ÷ 231
33 ÷ 211
11 ÷ 201

Reading the remainders from bottom to top gives 11111101000

11111101000 in binary is 7E8 in hex

Binary to hex: group the bits in 4s

Because 16 = 2⁴, every 4 bits make exactly one hex digit. Start from the right and pad the leftmost group with zeros if needed.

4-bit groupValueHex digit
011177
111014E
100088

0111 1110 1000 → 7E8

Binary, decimal, hex and octal table

DecimalBinaryHexOctal
0000
1111
21022
31133
410044
510155
611066
711177
81000810
91001911
101010A12
111011B13
121100C14
131101D15
141110E16
151111F17
16100001020
321000002040
64100000040100
100110010064144
12711111117F177
1281000000080200
25511111111FF377
256100000000100400
100011111010003E81750
1024100000000004002000
40961000000000000100010000
655351111111111111111FFFF177777

Where you need to convert between bases

  • Colour codes: the hex colour #FF8000 is red 255, green 128 and blue 0 in decimal.
  • Unix file permissions, which are octal: 755 is 111 101 101 in binary, read, write and execute for the owner and read and execute for everyone else.
  • Debugging: memory addresses, error codes and register values are usually printed in hex and documented in decimal, or the other way round.
  • Networking: IPv4 addresses and subnet masks are easier to reason about in binary, and IPv6 addresses are written in hex.

Frequently asked questions

Which number base is which?

Decimal is base 10, the everyday system with digits 0 to 9. Binary is base 2 (0 and 1), octal is base 8 (0 to 7) and hexadecimal, or hex, is base 16 (0 to 9 then A to F for 10 to 15).

Why do programmers use hex instead of binary?

Each hex digit stands for exactly 4 bits, so a byte is always two hex digits. FF is much easier to read and type than 11111111, and converting between the two is a simple lookup.

Can I convert negative numbers?

Yes. A minus sign is kept in every result, so -255 becomes -11111111 in binary and -FF in hex. The converter does not produce two's complement, which depends on how many bits the value is stored in.

Is there a size limit?

No practical limit. The conversion uses arbitrary precision integers, so long values stay exact. The step-by-step working is shown for numbers up to 24 digits.

Does it handle prefixes such as 0x and 0b?

Yes. 0x for hex, 0b for binary and 0o for octal are removed before converting, as are spaces and underscores used to group digits.

Single conversion tools

Each of these pages converts one way and explains that method in more detail. For text, try Text to Binary or Character to ASCII code.

Local Processing
End-to-End Encryption
Works Offline

Building Something Beyond This Tool?

We help teams design and build reliable web and mobile applications backed by well-structured APIs.