Number Base Converter
Convert integers between binary, octal, decimal and hexadecimal. Handles very large numbers and 0x, 0b and 0o prefixes.
Convert integers between binary, octal, decimal and hexadecimal. Handles very large numbers and 0x, 0b and 0o prefixes.
Programmers often switch between number bases: binary for bit flags, hexadecimal for colors and memory addresses, decimal for everyday values.
Enter a number, choose its base (or use a 0x, 0b or 0o prefix), and see it in all four bases.
255 = 11111111 (binary) = 377 (octal) = FF (hex)
A positional number system writes a value as digits multiplied by powers of the base. Binary uses powers of 2, octal powers of 8, and hexadecimal powers of 16. The bases 2, 8 and 16 are related: one hex digit equals exactly four bits and one octal digit equals three bits, which is why programmers read memory dumps and bit masks in hex. For example, binary 1111 1111 groups into two hex digits ff, which equals 255 in decimal.
The converter uses BigInt, so integers are exact beyond 2 to the power 53, the point at which ordinary JavaScript numbers start losing precision. Negative numbers are shown with a minus sign rather than in two's complement, which is how processors store signed integers. If you need the two's complement bit pattern, you must choose a width such as 8 or 32 bits and compute it separately. Prefixes 0x, 0b and 0o are common conventions in many programming languages for marking the base.
No. Only whole numbers (integers) are supported.
Very large. It uses BigInt, so there is no 53-bit limit.
With a minus sign in each base, not as two's complement.
No. It runs in your browser.
Each hex digit maps to exactly four bits, so a byte is always two hex digits. That makes binary data compact and easy to read compared with long strings of ones and zeros.
Binary allows 0 and 1, octal 0 to 7, decimal 0 to 9, and hexadecimal 0 to 9 plus a to f. A digit outside the chosen base produces an error.