ToolsTray

Star a tool to keep it here.

Number Base Converter

Number base converter for binary, octal, decimal and hex, reading input written in any base from 2 to 36. BigInt math, so a 128-bit value converts exactly.

Binary

111111118-bit

8 bits, one byte, every bit set. 1111 1111 = 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1.

Octal377
Decimalas typed255
Hexff
Base 3673digits 0-9 then a-z

Read as decimal from the Value box; unsigned at this width.

Bit width

How to use

  1. Set From base to whatever the number is already written in. Decimal (10) is preselected, with Binary (2), Octal (8) and Hex (16) above the plain Base 3 through Base 36 entries. A 0x, 0b or 0o prefix sets it for you.
  2. Key the digits into Value. Spaces, underscores or commas between digits are fine; the box names what it took out.
  3. Pick a Bit width. The binary pads to it and a negative becomes its two's complement word; Signed keeps the minus sign on every card instead.
  4. Set Also in base to any base from 2 to 36 for the fourth card, then press Copy binary or the copy icon on the card you came for.

What a base actually is

A number base converter earns its keep the moment you are staring at a register value in hex and need to see the bits. Type the digits into Value, tell the From base menu which system they are written in, and the binary comes back first, in groups of four and padded to the word width you pick, with octal, decimal, hex and one more base of your choosing in the cards underneath. There is no Convert button to press. Paste 0xff, 0b1010 or 0o17 and the prefix sets From base for you; spaces, underscores and commas between digits come out, and the box says how many it dropped.

A base, or radix, is just how many distinct digits a system uses before it carries. Decimal has ten of them. Binary has two. Hex has sixteen, which is why it borrows a to f once the numerals run out, and base 36 goes all the way to z. The arithmetic here runs on BigInt, so a 32-digit hex value or a very long binary string comes back exact instead of rounding off past 2^53 the way a double-precision calculator does. Letters can be upper or lower case. A negative number is written as a two's complement word at 8, 16, 32 or 64 bits, the way a register holds it, and the Signed chip gives the plain minus-sign form instead.

One byte, four ways

Leave From base on Decimal (10) and key in 202. Binary reads 1100 1010, octal reads 312, hex reads ca. That is a single byte, and under the bits the page writes the place values out: 128 + 64 + 8 + 2. Type 2 instead and the binary still fills the byte, as 0000 0010.

Now flip From base to Hex (16) and type ca. Decimal reads 202 again. The output is lowercase and bare, so it is ca rather than 0xCA, and every copy button writes the plain digits with no spaces in them.

Good to know

  • Integers only. A decimal point stops it dead, so 10.5 or binary 0.1 has nowhere to go here.
  • A negative that does not fit the width you picked is shown at the next width that holds it, and one wider than 64 bits falls back to the signed form. Nothing here cuts a value down to make it fit.
  • One extra base at a time. Also in base gives a fourth card in any base from 2 to 36, not a table of every base at once.

Frequently asked questions

Which bases can I type into?

Anything from 2 to 36 on the way in, and the same range on the way out through Also in base. Bases past 10 borrow letters as digits, so a counts as 10, f as 15, and z as 35 in base 36.

How do I convert binary to decimal by hand?

Multiply each digit by its power of two and add up the results. For 1010 that is 8 + 0 + 2 + 0, which gives 10. Going back the other way, divide by two over and over and read the remainders bottom to top. The same recipe works for any base once you swap the two for your radix.

Will it handle a 128-bit number?

Yes. Conversions run on BigInt, so there is no silent overflow at 64 bits and no rounding at JavaScript's 2^53 safe-integer line. Paste in 32 hex digits and the binary comes back with all 128 bits intact.

Why did From base change by itself?

Because the value started with a prefix. 0x means hex, 0b binary and 0o octal, so pasting 0xff with Decimal selected moves From base to Hex (16) and says so under the box. The exception is a prefix letter that is already a digit of the base you chose: in hex, b is eleven, so 0b1 stays the hex number 177.

Can I paste a minus sign?

Go ahead, and a leading plus is accepted too. At a bit width the negative is written the way a register stores it, so -10 at 32-bit reads ffff fff6 in hex. Pick Signed and every card keeps the minus instead: -1010, -12 and -a.

Does it turn #ff8800 into RGB values?

Not as three channels. It reads the whole thing as one integer, so strip the # and ff8800 gives you 16746496 in decimal for the lot. Splitting a hex colour into red, green and blue is the colour converter's job.

What is base 36 for?

It squeezes a number into the fewest characters you can still type on a keyboard, using 0-9 then a-z. Short URL slugs and compact ids often use it. Base 36 is where this converter stops, because 36 is how many digits the Latin alphabet plus the numerals gives you.

Missing something in Number Base Converter? Suggest a feature →

Tell someone who needs this.