About the Number Base Converter
Type an integer in binary, octal, decimal or hexadecimal and see it in all four bases at once, each with its own Copy button. It is handy for reading memory addresses, bit masks, Unix permissions or hex color channels. Hex input can include an optional 0x prefix and either letter case, and hex output is always uppercase.
How to use the Number Base Converter
- Choose the base you are typing in from Input base: Binary (2), Octal (8), Decimal (10) or Hexadecimal (16).
- Type the value into Enter number.
- Read the binary, octal, decimal and hexadecimal results.
- Click Copy next to the one you need.
Worked example: decimal 2024 in every base
Check the hex: 7 x 256 + 14 x 16 + 8 = 1,792 + 224 + 8 = 2,024 (E is 14). Each hex digit maps to four bits, so 7E8 is 0111 1110 1000, the same as the binary result once the leading zero is dropped.
2024Binary (base 2) 11111101000
Octal (base 8) 3750
Decimal (base 10) 2024
Hexadecimal (base 16) 7E8How input is read
The converter reads digits from the left and stops at the first character that is not valid in the chosen base, without warning you. In binary mode, 102 is read as 10 and shows decimal 2. In hex mode, 1G is read as 1. In decimal mode, 12.9 becomes 12, because only whole numbers are converted.
A matching prefix is accepted: 0x in hex mode, 0b in binary and 0o in octal, so 0x7E4 and 7E4 both give 2020. A character that is not a digit of the chosen base, such as 2 in binary or G in hex, shows an error naming it instead of a result. Negative numbers keep a minus sign in every base: -42 becomes -101010, -52 and -2A. This is a signed value, not the two's complement bit pattern a CPU stores.
Size limit
Values are exact up to 9,007,199,254,740,991 (2^53 - 1), the largest integer JavaScript stores without rounding. Beyond that, digits are lost. FFFFFFFFFFFFFFFF (the largest unsigned 64-bit value) converts to 18446744073709552000 instead of the correct 18446744073709551615, so do not trust results above 2^53 for 64-bit work.
For colors, convert each two-digit channel on its own: 3B, 82 and F6 give 59, 130 and 246. The color picker does that split for you.
How positional number systems work
Every positional number system uses a base (radix). Decimal (base 10) uses digits 0-9. Binary (base 2) uses 0-1. Octal (base 8) uses 0-7. Hexadecimal (base 16) uses 0-9 plus A-F for values 10-15. The position of each digit represents a power of the base: rightmost is base^0, next is base^1, and so on.
Example: decimal 255 = 2 times 10^2 + 5 times 10^1 + 5 times 10^0. Binary 11111111 = sum of 2^7 through 2^0 = 255. Hex FF = 15 times 16 + 15 = 255. All three represent the same value.
Practical uses in programming
Hex is everywhere in low-level programming: memory addresses (0x7FFE4C2B), byte masks (0xFF), CSS color values (#3B82F6 = R:59, G:130, B:246), and bitwise operations. Binary is used when individual bits matter: permission flags, protocol headers, and bitwise AND/OR operations.
Octal still appears in Unix permissions. chmod 755 sets owner=rwx (7=111 in binary), group=r-x (5=101), others=r-x (5=101). Understanding the octal-to-binary relationship makes permission strings intuitive.
Number Base Converter: frequently asked questions
- How do I convert decimal to binary?
- Repeatedly divide by 2 and record remainders bottom to top. For 25: 25/2=12R1, 12/2=6R0, 6/2=3R0, 3/2=1R1, 1/2=0R1. Read remainders bottom to top: 11001.
- Why do programmers use hexadecimal?
- Each hex digit represents exactly 4 binary bits, making hex a compact human-readable representation of binary data. Two hex digits equal one byte. Memory addresses, color codes, and binary file data are naturally expressed in hex.
- What is octal used for?
- Octal mainly appears in Unix file permissions (chmod 755 means rwxr-xr-x). Each octal digit represents 3 binary bits.
- Can this converter handle negative numbers?
- Yes. Negative numbers show with a minus sign in all bases. For two's complement (how computers store negatives), the representation for -N in n bits is (2^n) - N.