Number Base Converter
Convert numbers between binary, octal, decimal and hex. Paste 255, 0xFF or 0b11111111 and get every base back, with no rounding.
Runs in your browser — your input is processed on this device and never uploaded.
Input
Integer to convert. Optional leading + or -. Auto-detects 0x hex, 0b binary, 0o octal, otherwise decimal. Underscores allowed. Maximum 8 KiB and 2048 digits.
Result
Results appear here.
About this tool
On this page
What is a number base converter?
The same integer can be written in binary (base 2), octal (base 8), decimal (base 10) or hexadecimal (base 16). Programmers paste 255, 0xFF or 0b11111111 and want the other forms without losing precision to a floating-point calculator.
Paste a value and this tool returns it in decimal, hex, octal and binary, plus the base it read, whether it was negative, and its bit length.
Number base converter options
- Value
- Optional leading + or -. A 0x or 0X prefix means hex, 0b or 0B binary, 0o or 0O octal, and anything else is decimal. Underscores are allowed as digit separators, the same way Rust and Python literals use them. Up to 8 KiB of text and 2048 digits after the underscores are removed.
- From base
- Leave empty to detect it from the prefix. Set 2 through 36 to force a base. A 0x, 0b or 0o prefix that agrees with that base is still accepted.
- Uppercase hex
- Off by default. Turn it on to write the hex letters as A through F.
- Leading zeros do not count. Zero has a bit length of 0, and -0 is not reported as negative.
- The digit strings are unsigned magnitudes with a separate negative flag. This is not two's complement.
Why convert bases here instead of a calculator
Many calculators store a floating-point number. Large hex constants, 128-bit values and anything past 2^53 lose their low bits before you see them. This converter uses an arbitrary-precision integer, capped at 2048 digits, so the result is exactly the integer you pasted.
Prefix detection is there because people paste literals straight from code. If the digits do not fit the prefix, the tool refuses with an error instead of reading a different number.
Number base converter alternatives
bc, Python's int(x, base) and your language's own literals do the same job locally. This page saves you opening a terminal for one number.
Hex Encoder and Decoder, Base64 and Multibase encode byte sequences and keep leading zero bytes. Use those when the input is binary data, and this page when it is one number.
Warning
Do not use the hex output as the bytes of a buffer. A leading 00 byte disappears here on purpose.
Things to know about number bases
C's leading-zero octal (077) is not detected. Only the 0o prefix means octal, so 077 is seventy-seven. That avoids the surprise where a zero-padded decimal turns into a different number.
Bases 11 through 36 use letters as digits, so base 36 runs from 0 to Z. With from base set to 16, ff works without the 0x prefix.
Bit length is the number of bits needed for the magnitude, not counting a sign bit. 255 needs 8 bits and 256 needs 9.
Browse
Find similar tools by category or tag.