Home › Developer Tools › Binary Converter
Binary Converter
Computers store everything in binary, but people read decimal and programmers read hexadecimal. Enter a number in any base and this converter shows it in all four bases at once, plus how many bits it needs, what it means as a signed number, and which ASCII character it is when it falls in the printable range.
Only whole numbers are converted — bases are about counting, not fractions. Hexadecimal letters may be upper or lower case. Very large numbers (above 2^53) lose exactness in JavaScript, so results beyond about 15 decimal digits are approximate.
How it works
Each base counts with a different set of digits: binary uses 0-1, octal 0-7, decimal 0-9, hexadecimal 0-9 plus A-F (A = 10 through F = 15). To convert, read the digits as powers of the base: 101010 in binary = 1×32 + 0×16 + 1×8 + 0×4 + 1×2 + 0×1 = 42. The same 42 in octal is 52 (5×8 + 2) and in hexadecimal is 2A (2×16 + 10). Bits needed is the length of the binary form; the signed value treats the smallest whole number of bytes as a two's-complement number, so 255 in 8 bits reads as −1 signed — that is how computers store negative numbers. Worked example: 255 decimal = 11111111 binary (all eight bits set) = 377 octal = FF hexadecimal, and as an 8-bit signed number it is −1. Worked example 2: FF hexadecimal = 15×16 + 15 = 255 decimal = 11111111 binary.
Frequently asked questions
Why do programmers use hexadecimal?
One hex digit is exactly four bits, so a byte is always two hex digits. 11111111 is hard to read at a glance; FF is not. Hex is just a compact way of writing binary, which is why colors, memory addresses and hashes are written in hex.
What is the difference between a bit and a byte?
A bit is one binary digit, 0 or 1. A byte is eight bits, enough for 256 values (0-255 unsigned, or -128 to 127 signed). File sizes, memory and network speeds are all counted in bytes and their multiples.
Why does 255 read as -1 when signed?
In two's complement, the top bit is the sign: an 8-bit pattern starting with 1 is negative, and its value is the unsigned value minus 256. So 11111111 = 255 - 256 = -1. This is how nearly every computer stores negative integers.
What do the 0x and 0b prefixes mean?
They are labels, not part of the number: 0x marks hexadecimal (0xFF = 255) and 0b marks binary (0b1010 = 10). This converter accepts them and strips them before converting.
Why do large numbers become approximate?
JavaScript numbers are exact only up to 2^53 (about 9,007,199,254,740,992). Beyond that, neighbouring integers round to the same value, so conversions of very large numbers can be off by one or more. For everyday sizes this never matters.