DEV-003
Binary, Decimal & Hex Converter
Four boxes, one number. Type into any of them and the other three follow, so there is no direction to choose and no convert button to press. Values are exact at any size, which matters the moment you paste in something 64 bits wide.
- Free
- No signup
- Private · runs locally
- Bits used
- 8
- Smallest that fits
- 8-bit
- Bits set to 1
- 8
- Even or odd
- Odd
Type in any box and the other three follow. Values are exact at any size, so a 64-bit hex value converts without rounding.
How to use it
- Type into whichever box matches what you have. Binary accepts 0 and 1, hexadecimal accepts 0 to 9 and A to F.
- The other three update immediately.
- Use the copy button on any row to take that representation.
- The figures underneath show how many bits the value uses and the smallest standard size it fits in.
Why bit length is shown
The question behind most hex-to-decimal conversions is not really what the number is, it is whether it fits. A value that needs 9 bits will not go into a byte, and one that needs 33 will not go into a 32-bit integer, which is the kind of thing that silently truncates rather than failing loudly.
The count of bits set to 1 is there for the same reason: it is what you need when the number is a bitmask of flags rather than a quantity.
Large values are handled exactly
JavaScript's ordinary numbers lose precision above about 9 quadrillion, which is 2 to the power of 53. Any tool that converts through them will quietly round a 64-bit hex value, and the digits you get back will look plausible and be wrong.
This uses arbitrary-precision integers throughout, so a full 64-bit value, or a far larger one, converts digit for digit. The only limit is a cap of 512 digits, which exists so that pasting something enormous cannot freeze the page.
Frequently asked questions
What do the 0b, 0o and 0x prefixes mean?
They are the markers most programming languages use to say which base a literal is written in: 0b for binary, 0o for octal and 0x for hexadecimal. They are shown here as labels and are not part of the value, so you do not need to type them.
Does it handle negative numbers?
No. Negative values in binary depend on how many bits you are working in and which representation you are using, usually two's complement, so there is no single correct answer without that context. This converts unsigned values only.
Can I convert fractions or decimals?
No, whole numbers only. Fractional binary is a different problem, and the answer is usually about floating point representation rather than base conversion.
Why is hexadecimal shown in capitals?
Only for readability, since A to F stand out from the digits more clearly. Hexadecimal is not case sensitive, and you can type it either way.
Related tools
Other tools people use alongside the Base Converter.
- DEV-002Base64 Encoder & DecoderEncode text to Base64 or decode Base64 back to text.Open
- DEV-001JSON FormatterFormat, minify and validate JSON with clear error messages.Open
- CAL-012Unit ConverterConvert length, weight, volume, area, speed and temperature between metric and imperial.Open
Browse all developer tools or see every tool.