Number Base Converter

Convert a whole number between binary, octal, decimal, hexadecimal and any base up to 36.

Runs entirely in your browser. Nothing is uploaded, logged or stored.

Spaces, underscores and a 0x or 0b prefix are ignored.

Converted

255

Binary (2)
11111111
Octal (8)
377
Decimal (10)
255
Hexadecimal (16)
FF

The same number can be written in any base, and which one you meet depends on where you are looking: hexadecimal in a memory dump, binary in a permission mask, octal in a file mode, decimal everywhere else. This converts between all of them.

How it works

Digits run 0 to 9 then A to Z, which is what allows bases up to 36. Case is ignored on the way in, so ff and FF are the same number.

The conversion is done by repeated division on the digits themselves rather than by turning the input into a machine integer first. That matters more than it sounds: a 64-bit hash or a 128-bit identifier is exactly the sort of value people paste into a base converter, and anything that goes through a float silently rounds it past about sixteen digits.

Only whole numbers, and no negative sign. A fraction in another base is a different question with its own rounding, and answering it in passing would give a result that looks exact and is not.

Examples

Case Input Result
A byte in hexadecimal ff from base 16 255 in decimal, 11111111 in binary
A Unix file mode 755 from base 8 493 in decimal, 111101101 in binary
Larger than a machine integer, still exact ffffffffffffffffffffffff from base 16 79228162514264337593543950335

Frequently asked questions

Can it handle numbers bigger than 64 bits?

Yes. The arithmetic is done on the digit string, so length is not a limit and nothing is rounded. Try a full SHA-256 digest in base 16 and read it back in base 10.

Why are negative numbers not accepted?

Because how a negative number is written depends on a convention this tool cannot know: a minus sign, two's complement in some width, or a sign bit. Picking one silently would give a confidently wrong answer for the other two.

Are 0x and 0b prefixes allowed?

Yes, and so are spaces and underscores. They are notation rather than digits — 1010 1100 and 1010_1100 are the same number — so they are stripped before reading.

Why does base 36 stop there?

Because that is where the digits run out: ten numerals and twenty-six letters. Going further needs an alphabet that has to be agreed on first, as base 58 and base 64 each do in their own way.

Good to know

  • Whole numbers only, and no sign. A fraction in another base needs a rounding rule, and a negative one needs a convention — a minus sign, or two's complement in some width — that this tool cannot guess from the input alone.
  • The four common bases are always shown alongside the one you asked for, because the value you want to check against is usually one of them.

All Code tools