Free tool

Binary converter: binary, decimal, hex and octal

Type a number and get it in binary, octal, decimal and hex at once, or pick any base from 2 to 36. Big numbers stay exact, fractions show their repeating digits, and negative numbers come with their two’s complement bits.

Free · no sign-up · runs in your browser, nothing is uploaded

decimal input
one number per line for a list
binary result

111 1110 1010

11 bits

Binary (2)

111 1110 1010

Octal (8)

3752

Decimal (10)

2,026

Hex (16)

7EA

Bits and two’s complement
16-bit pattern
0000 0111 1110 1010
hex
0x07EA
bytes, big-endian
07 EA
bytes, little-endian
EA 07
as unsigned
2026
as signed
2026

Click a bit to flip it. The numbers under each byte are bit positions (0 is the lowest bit).

How decimal → binary works for this number

Divide the whole part (2026) by 2 again and again until the quotient is 0. The remainders, read from the bottom up, are the binary digits.

dividequotientremainder
2026 ÷ 210130
1013 ÷ 25061
506 ÷ 22530
253 ÷ 21261
126 ÷ 2630
63 ÷ 2311
31 ÷ 2151
15 ÷ 271
7 ÷ 231
3 ÷ 211
1 ÷ 201

Bottom up: 11111101010

Result: 11111101010 (binary)

How number bases work

A base (or radix) is how many different digits a number system uses. Decimal has ten (0-9), binary two (0 and 1), octal eight (0-7) and hexadecimal sixteen (0-9 and A-F). Each position is worth the base times the position to its right. In decimal the places are 1, 10, 100; in binary they are 1, 2, 4, 8; in hex 1, 16, 256.

So 1011 in binary is 1×8 + 0×4 + 1×2 + 1×1 = 11, and B in hex is also 11. The value is the same; only the way it is written changes. Programmers use hex because one hex digit is exactly four bits, so a byte is always two hex digits.

decbinaryoctalhex
0000000
1000111
2001022
3001133
4010044
5010155
6011066
7011177
81000108
91001119
10101012A
11101113B
12110014C
13110115D
14111016E
15111117F

Three ways to convert between bases

Any base to decimal: multiply each digit by its place value and add. 7DE in hex is 7×256 + 13×16 + 14 = 2014. The hex to decimal and binary to decimal pages walk through this for those bases.

Decimal to any base: divide by the base, keep the remainder, and repeat with the quotient until it is 0. The remainders read from the last to the first are the digits. See decimal to binary for the steps in detail.

Binary, octal and hex between each other: no arithmetic needed. Each hex digit is 4 bits and each octal digit is 3 bits, so you group the bits from the right and swap each group for its digit. 1011 0110 is B6 in hex; 10 110 110 is 266 in octal.

Negative numbers and two’s complement

Written by hand, a negative binary number just gets a minus sign: -10 is -1010. Inside a computer, integers have a fixed width (8, 16, 32 or 64 bits) and negatives are stored in two’s complement: invert every bit of the positive value and add 1.

Decimal8-bit two’s complementHex
1270111 11117F
10000 000101
00000 000000
-11111 1111FF
-51111 1011FB
-1281000 000080

The top bit tells you the sign. The same 8 bits 11111111 are 255 to an unsigned byte and -1 to a signed one; the bits do not say which. The converter shows both readings, and you can click any bit in the grid to flip it.

Convert number bases in code

JavaScript. toString(radix) and parseInt(string, radix) take any base from 2 to 36. Plain numbers lose precision above 2^53 - 1 (9,007,199,254,740,991), so use BigInt for anything larger.

(255).toString(2);          // '11111111'
(255).toString(16);         // 'ff'
parseInt('ff', 16);         // 255
parseInt('11111111', 2);    // 255
BigInt('0xFFFFFFFFFFFFFFFF').toString(10); // '18446744073709551615' (exact)
parseInt('FFFFFFFFFFFFFFFF', 16);          // 18446744073709552000 (rounded)

Python. int() takes a base from 2 to 36, or 0 to read the prefix. bin(), oct() and hex() go the other way, and integers never overflow.

int('ff', 16)        # 255
int('0b1010', 0)     # 10, base from the prefix
bin(10), hex(255)    # ('0b1010', '0xff')
format(10, '08b')    # '00001010'

Go

n, _ := strconv.ParseInt("ff", 16, 64)  // 255
strconv.FormatInt(255, 2)                // "11111111"
fmt.Sprintf("%08b %x %o", 10, 255, 8)    // "00001010 ff 10"

Bash

echo $((16#FF))            # 255
echo $((2#1010))           # 10
printf '%x\n' 255          # ff
echo "obase=2; 10" | bc    # 1010

Powers of two worth knowing

Place values in binary are powers of two, and so are most limits you meet in code: 2^8 values in a byte, 2^31 - 1 as the largest signed 32-bit integer, 2^53 as the edge of exact integers in a JavaScript number.

powerdecimalhex
2^010x1
2^120x2
2^240x4
2^380x8
2^4160x10
2^5320x20
2^6640x40
2^71280x80
2^82560x100
2^101,0240x400
2^124,0960x1000
2^1532,7680x8000
2^1665,5360x10000
2^201,048,5760x100000
2^2416,777,2160x1000000
2^312,147,483,6480x80000000
2^324,294,967,2960x100000000
2^539,007,199,254,740,9920x20000000000000
2^639,223,372,036,854,775,8080x8000000000000000
2^6418,446,744,073,709,551,6160x10000000000000000

For subnet masks, which are binary too, use the subnet calculator. To turn letters into bits, use text to binary. More command-line helpers are in the CLI tools on DevHunt.

FAQ

How do I convert binary to decimal?+

Multiply each bit by its place value (1, 2, 4, 8, 16 and so on, from the right) and add the results. 1011 is 8 + 0 + 2 + 1 = 11. Pick Binary as "From" and Decimal as "To" above to see the full working for any number.

What is 11111111 in decimal?+

255. It is eight 1 bits: 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1. It is the largest value one unsigned byte can hold, and FF in hex. Read as a signed 8-bit number (two’s complement), the same bits mean -1.

How do I convert binary to hex?+

Split the binary number into groups of 4 bits from the right, pad the leftmost group with zeros, and replace each group with one hex digit: 0000 is 0, 1001 is 9, 1010 is A, 1111 is F. So 1011 0110 is B6. The converter shows this grouping when you convert between binary and hex.

What is two’s complement?+

The way computers store negative integers. In N bits, a negative number -x is stored as 2^N - x, which is the same as inverting the bits of x and adding 1. In 8 bits, -1 is 11111111 and -128 is 10000000. Set a width in the "Bits and two’s complement" panel to see any number this way.

Why is 0.1 not exact in binary?+

A fraction ends in binary only when its denominator is a power of two. 0.1 is 1/10, and 10 has a factor of 5, so in binary it repeats forever: 0.0001100110011… Floating-point numbers store a rounded version, which is why 0.1 + 0.2 gives 0.30000000000000004 in JavaScript. Type 0.1 above and the converter shows the repeating part in brackets.

Which bases does this converter support?+

Every base from 2 to 36. Digits above 9 are the letters a to z, the same rule JavaScript, Python and Go use. Numbers are handled as exact big integers, so a 100-digit decimal number converts without rounding.

How many bits does a number need?+

A positive integer n needs floor(log2(n)) + 1 bits: 255 needs 8, 256 needs 9. Signed types need one more bit for the sign, so a signed 8-bit type holds -128 to 127. The converter picks the smallest of 8, 16, 32, 64 and 128 bits that fits.

Sources: MDN: Number.prototype.toString() · MDN: parseInt() · MDN: BigInt · MDN: Number.MAX_SAFE_INTEGER · Python: int() · Go: strconv · GNU bc manual. Checked 2026-10-30.