Binary / Hex / Octal / Decimal Converter
Convert numbers between binary, hexadecimal, octal, and decimal bases instantly.
このツールについて
The Binary / Hex / Octal / Decimal Converter lets you enter a number in any base and instantly see its representation in all four bases simultaneously. Type in the binary, hex, octal, or decimal field and the other three update in real time. Choose a bit width (8, 16, 32, or 64 bits) to see the two's complement representation for negative numbers. The tool also supports floating-point numbers in decimal input, showing the IEEE 754 binary representation. Each output field is selectable for easy copying. A bit-field visualization shows the individual bits of the 8/16/32-bit representation, color-coded by significance, making it ideal for embedded systems programmers and computer science students.
使い方
- 1 Select the bit width (8, 16, 32, or 64 bits) from the selector.
- 2 Type a number into any of the four input fields (Binary, Octal, Decimal, or Hex).
- 3 The other three fields update instantly with the converted values.
- 4 For negative numbers, type a minus sign before the decimal value.
- 5 Click any field to select all text for easy copying.
- 6 Toggle the bit visualizer to see individual bits highlighted by value.
Why the same number wears four different costumes
A whole number like forty-two has no single "true" written form — 42 is just how we group it into powers of ten. A computer prefers powers of two, so it stores that same quantity as 00101010. Hexadecimal (0x2A) and octal (0o52) are shorthand for that binary, packing four or three bits into a single digit so humans can read raw memory without counting zeros. This converter holds one underlying value and shows it in all four bases at once, so editing any field instantly re-renders the other three. Internally it stores the number as a JavaScript BigInt, which is why 64-bit values stay exact instead of rounding the way ordinary floating-point numbers would.
How a base conversion actually works
Converting between bases never changes the value — only its grouping. To read binary, each position is a power of two, doubling from right to left: 1, 2, 4, 8, 16, 32, 64, 128. Add up the positions that hold a 1. To go the other way, repeatedly divide by the target base and read the remainders bottom-to-top. Hexadecimal is special because one hex digit equals exactly four binary digits (a "nibble"), so you can convert by sight in groups of four. That is the relationship the bit visualizer below the fields makes concrete: it labels each four-bit group with its hex digit.
A worked example: 42 across every base
Type 42 into the decimal field. The converter walks down from the highest power of two that fits: 32 fits (leaving 10), 8 fits (leaving 2), 2 fits (leaving 0). The bits that fired are 32, 8, and 2 — positions 5, 3, and 1 — giving binary 00101010. Split that into nibbles, 0010 and 1010, which read as hex 2 and A, so the hex field shows 0x2A. Grouped into threes from the right, 101010 becomes 52 in octal. The info panel also reports the highest set bit (bit 5) and the signed interpretation, which for 42 is simply 42 because the top bit is clear.
Two's complement and the bit-width selector
Negative numbers are where most people stumble. Computers do not store a separate minus sign; instead they use two's complement, where the most significant bit carries a negative weight. The bit-width buttons (8, 16, 32, 64) decide how many bits that representation spans, and the value wraps to fit. Enter -1 in 8-bit mode and every bit turns on: 11111111, hex 0xFF. Switch to 32-bit and the same -1 becomes 0xFFFFFFFF. The rule for negating by hand is "flip every bit, then add one." The "Signed (two's complement)" line in the info panel shows how the current bit pattern would be read as a signed integer — so a stored 0xFF reads as -1 under 8 bits but as 255 if you treat it as unsigned.
Genuine use cases
- Reading hardware registers. Embedded and driver code is full of hex masks like
0x20. Paste it in to see which individual bits (bit 5 here) a flag actually toggles. - Building bit masks. Want a mask for "bits 0, 1, and 4"? Type binary
00010011and read off hex0x13to drop into your code. - Debugging color and permission values. Unix file modes (
0o755) and packed RGBA values become readable when you can flip between octal, hex, and binary in one view. - Learning and teaching. The color-coded bit grid turns the abstract idea of "place value in base two" into something you can watch change as you type.
Common mistakes the tool guards against
- Confusing signed and unsigned. The byte
0xFFis 255 unsigned but -1 signed — same bits, different meaning. Always know which interpretation your code expects; the info panel shows you both. - Forgetting the prefix.
10in binary is two, in decimal is ten, in hex is sixteen. The field labels remove that ambiguity, and you can type with or without the0x,0o,0bprefixes — the tool strips them for you. - Overflowing the bit width. If you enter a value too large for 8 bits, it wraps rather than erroring, mirroring how a real register behaves. Widen the bit width if you need the full number.
- Leading-zero octal traps. In many languages a leading zero (
052) silently means octal. This tool keeps the bases in clearly separate fields so that surprise never bites you.
Is anything sent to a server?
No. Every conversion runs in your browser using built-in BigInt arithmetic — there is no network request, so the numbers you enter never leave your device. You can disconnect from the internet and the converter keeps working exactly the same.