Number Base Converter
Convert between binary, octal, decimal and hex.
About this tool
Type a number in binary, octal, decimal or hexadecimal and see it in all the others, along with its bits grouped into bytes. Handles arbitrarily large integers and recognises 0x, 0b and 0o prefixes.
How to use it
- Type a number into any of the four fields: binary, octal, decimal or hexadecimal.
- The other fields update instantly. Prefixes like 0x, 0b and 0o are accepted.
- Check the bits panel to see the value split into bytes.
Questions
- How big a number can it handle?
- Any size. It uses JavaScript BigInt, so there is no 32-bit or 64-bit limit and no rounding.
- Why do hex numbers start with 0x?
- It is a convention from C, now used by most languages, to show that the digits are hexadecimal. Similarly 0b marks binary and 0o marks octal.
- Where is octal still used?
- Mainly for Unix file permissions, where 755 means rwxr-xr-x. Each octal digit maps neatly onto three permission bits.
- How do I convert hex to ASCII text?
- This tool converts numbers, not strings. In hex text, each pair of digits is one byte, which you look up in an ASCII table: 48 65 6C 6C 6F spells “Hello”. On the command line, echo 48656c6c6f | xxd -r -p turns a hex string back into text.
- Can it convert fractions or numbers with a decimal point?
- No, only whole numbers. Fractions are tricky in binary anyway: 0.1 in decimal has no exact binary form and repeats forever, which is why 0.1 + 0.2 isn’t exactly 0.3 in most programming languages. Floating-point values are stored in the IEEE 754 format, not as plain binary integers.
- What is the largest number that fits in 8, 16, 32 or 64 bits?
- Unsigned, it is 2ⁿ − 1: 255, 65,535, 4,294,967,295 and 18,446,744,073,709,551,615. Signed values reach about half that, such as 2,147,483,647 for 32 bits. JavaScript numbers are only exact up to 9,007,199,254,740,991, so this tool uses BigInt to stay precise beyond that.
How to convert binary to decimal, and back
Each digit of a binary number is worth a power of two, starting with 1 on the right. To convert 1011 to decimal, add up the positions that hold a 1: 8 + 0 + 2 + 1 = 11. Hexadecimal works the same way with powers of 16, so 0x2F is 2 × 16 + 15 = 47. Octal uses powers of eight. One rule covers every base: each digit times the base raised to its position.
To go the other way, divide by the target base repeatedly and write down the remainders from last to first. Dividing 11 by 2 again and again leaves remainders 1, 1, 0 and 1, which read backwards give 1011. With this number base converter you just type into any field and the other three update. In code, JavaScript has parseInt(text, 2) and n.toString(16), and Python has int(text, 2) and hex(n).
Why do programmers use hexadecimal?
One hex digit stands for exactly four bits, so two hex digits describe one byte. That makes hex a compact, readable way to write binary data: 11111111 is FF, and any 32-bit value fits in eight characters. You meet it in memory addresses, colour codes like #FF8800, hashes, MAC addresses, Unicode code points such as U+1F680, and the byte dumps printed by tools like xxd and hexdump.
The bits panel here shows the link directly. The value is padded to whole bytes, and each group of eight bits is shown with its two-digit hex value underneath. 48879 becomes 10111110 11101111, labelled BE and EF, which is why it reads as 0xBEEF. This makes it easy to check flags, bit masks and byte boundaries. The Subnet Calculator applies the same binary view to IPv4 addresses and netmasks.
How negative numbers work in binary: two’s complement
Computers usually store signed integers in two’s complement. To write −1 in 8 bits, invert every bit of 1 and add one: 00000001 becomes 11111110, plus one gives 11111111, or 0xFF. The top bit acts as the sign, so an 8-bit signed value ranges from −128 to 127, while the same bits read as unsigned run from 0 to 255. The bit pattern is identical; only the interpretation changes.
This converter works with plain integers, not fixed-width registers. Type -5 and you get -101 in binary and -5 in hex, with the minus sign kept in front instead of a two’s complement pattern. To get the 8-bit pattern of a negative number, add 256 first: −5 + 256 = 251, which is 0xFB. For 32 bits, add 4294967296. Spaces and underscores are ignored, so 1111_1011 works as input.
Decimal, hex, binary and octal table
The numbers you will look up most often, in all four bases.
| Decimal | Hexadecimal | Binary | Octal |
|---|---|---|---|
0 | 0x0 | 0000 | 0o0 |
1 | 0x1 | 0001 | 0o1 |
2 | 0x2 | 0010 | 0o2 |
3 | 0x3 | 0011 | 0o3 |
4 | 0x4 | 0100 | 0o4 |
5 | 0x5 | 0101 | 0o5 |
6 | 0x6 | 0110 | 0o6 |
7 | 0x7 | 0111 | 0o7 |
8 | 0x8 | 1000 | 0o10 |
9 | 0x9 | 1001 | 0o11 |
10 | 0xA | 1010 | 0o12 |
11 | 0xB | 1011 | 0o13 |
12 | 0xC | 1100 | 0o14 |
13 | 0xD | 1101 | 0o15 |
14 | 0xE | 1110 | 0o16 |
15 | 0xF | 1111 | 0o17 |
16 | 0x10 | 0001 0000 | 0o20 |
32 | 0x20 | 0010 0000 | 0o40 |
64 | 0x40 | 0100 0000 | 0o100 |
100 | 0x64 | 0110 0100 | 0o144 |
127 | 0x7F | 0111 1111 | 0o177 |
128 | 0x80 | 1000 0000 | 0o200 |
255 | 0xFF | 1111 1111 | 0o377 |
256 | 0x100 | 0001 0000 0000 | 0o400 |
512 | 0x200 | 0010 0000 0000 | 0o1000 |
1000 | 0x3E8 | 0011 1110 1000 | 0o1750 |
1024 | 0x400 | 0100 0000 0000 | 0o2000 |
4096 | 0x1000 | 0001 0000 0000 0000 | 0o10000 |
65535 | 0xFFFF | 1111 1111 1111 1111 | 0o177777 |
Something not working, or a result looks wrong? Report a problem with this tool