Number base converter
Convert whole numbers between binary, octal, decimal, hexadecimal and any base up to 36, with two’s complement and text codes.
How to use
Type a whole number and choose the base it is written in, or leave Automatic: then 0x means hexadecimal, 0o octal, 0b binary, and anything else decimal. The result shows the number in decimal, binary, octal and hexadecimal, each with a copy button, and in one more base of your choice from 2 to 36. Spaces and underscores between digits are ignored, so 1_000_000 works.
Bases above 10 use letters after the digit 9: a is 10, f is 15 and z is 35, which is why base 36 is the highest. Numbers of any length are converted exactly. Ordinary JavaScript numbers are only exact up to 9,007,199,254,740,991 (2⁵³ − 1); beyond that, many converters round the last digits without saying so.
For negative numbers, the result also shows two’s complement, the way processors store signed integers, at 8, 16, 32 or 64 bits. A signed n-bit integer holds −2ⁿ⁻¹ to 2ⁿ⁻¹ − 1, so 8 bits hold −128 to 127; a number that does not fit is flagged, and a positive one that fits only without a sign is shown as unsigned. Binary digits can be grouped in fours or eights to make long values easier to read; the copy button always copies them without spaces.
Text mode turns text into the bytes UTF-8 uses to store it, in binary, decimal and hexadecimal, with the Unicode code point of each character, and turns byte codes back into text. Everything runs in your browser.
Example
−5 in 8-bit two’s complement is 11111011, FB in hexadecimal: the processor stores 256 − 5 = 251.
255Binary 11111111, octal 377, hexadecimal FF.-5 at 8 bitsTwo’s complement 11111011, 0xFB.90071992547409932⁵³ + 1, converted exactly: hexadecimal 20000000000001. An ordinary JavaScript number would turn it into …992.€ in text modeUTF-8 bytes E2 82 AC: three bytes for one character, code point U+20AC.
Frequently asked questions
Why does hexadecimal use letters?
Base 16 needs sixteen digits, and 0 to 9 are only ten. The letters a to f stand for 10 to 15, so ff is 15 × 16 + 15 = 255. Upper or lower case means the same.
What is two’s complement?
The usual way computers store negative whole numbers: in n bits, a negative number −x is stored as 2ⁿ − x. With 8 bits, −1 is 11111111 and −128 is 10000000. It lets the processor add and subtract signed and unsigned numbers in the same way.
Why do some converters get large numbers wrong?
Because they use JavaScript’s ordinary numbers, which are exact only up to 9,007,199,254,740,991. This tool uses whole-number arithmetic of any size, so every digit is kept.
What do 0x, 0o and 0b mean?
They are prefixes used in programming languages such as JavaScript and Python: 0x for hexadecimal, 0o for octal and 0b for binary. In Automatic mode the tool reads them; with a base chosen, a matching prefix is also accepted.
Is anything I type sent anywhere?
No. The conversion runs in your browser.