Number Base Converter
Convert numbers between binary, octal, decimal, hexadecimal and any base 2–36. Handles huge BigInt values, negatives, fractions and two's complement in your browser.
How to use Number Base Converter
- 1Type or paste a number, with a 0b, 0o or 0x prefix or with the From base set.
- 2Read the binary, octal, decimal, hex and custom-base results, or switch to All bases or Bits.
- 3Copy the result, with digit grouping or a prefix if you want them.
What makes it better
- Any input base from 2 to 36, plus prefix detection for 0b, 0o and 0x
- BigInt maths: numbers with hundreds of digits stay exact
- Two's complement for 8, 16, 32 and 64 bits, with a clear overflow message
- Fractions such as 0.1 convert to a set number of digits, and the page says when digits were cut
- Modes: Convert, All bases (2 to 36 in one table) and Bits (bit positions, signed and unsigned values, byte order)
About Number Base Converter
This converter reads a number in any base from 2 to 36, or detects a 0b, 0o or 0x prefix, and writes it in binary, octal, decimal, hexadecimal and one base of your choice. It uses BigInt, so a value such as 2^200 is converted digit for digit, and it can also list every base from 2 to 36 or show a bit-by-bit two's complement view for 8, 16, 32 and 64 bits.
Common uses
- Check a hex colour, memory address or bitmask against its binary and decimal forms.
- Work out what -5 looks like as an 8-bit or 16-bit two's complement value for a computer science exercise.
- Convert an ID or hash fragment between base 16, base 32 and base 36.
- See which bits are set in a flag value and how its bytes are ordered in memory.
Example
Input
0xFF
Result
Binary: 11111111 Octal: 377 Decimal: 255 Hexadecimal: FF Custom (base 36): 73
Good to know
- Fractional parts are truncated, not rounded, after the number of digits you choose, and the page lists which bases are therefore not exact. Many decimal fractions, such as 0.1, never end in binary.
- Two's complement is shown only for whole numbers. A value that does not fit the chosen width gets an overflow message with the valid signed and unsigned ranges instead of being wrapped around.
- Input is limited to 5,000 digits. Spaces and underscores inside a number are ignored, and letters are read case-insensitively.
Number Base Converter FAQ
How do I convert binary to decimal or hex?
Choose From base 2 (or start the number with 0b), type the bits, and the decimal and hexadecimal rows update together. Spaces between groups of four bits are allowed, so 1111 0000 reads as 240 decimal or F0 in hex.
What does the 0x, 0b or 0o in front of a number mean?
They are prefixes used in programming languages: 0x means hexadecimal, 0b binary and 0o octal. With From base on Auto the converter uses the prefix to pick the base, and without a prefix it assumes decimal.
How is two's complement calculated for a negative number?
The magnitude is written in binary, every bit is flipped and 1 is added, which is the same as adding 2 to the power of the bit width to the negative value. For example -5 in 8 bits is 11111011, or FB in hex.
Why can this converter handle numbers larger than 2^53?
Ordinary JavaScript numbers lose exactness above 2^53, but this page does its arithmetic with BigInt integers, which have no fixed size. A 200-digit number is converted exactly, up to a 5,000-digit input limit.
Can I convert fractions like 0.625 to binary?
Yes. 0.625 becomes 0.101 in binary. Fractions that cannot be written exactly in the target base, such as 0.1 in binary, are cut after the number of fractional digits you pick, and a message names the bases affected.