Number Base Converter

Convert a number — or a whole list of them — between binary, octal, decimal, hexadecimal and any other base up to 36.

Runs on your deviceConvertersWorkingNo account needed

What this tool does

Number Base Converter reads each line as a number written in one base and rewrites it in another, anywhere from base 2 to base 36. Thirty-six is the ceiling because that is where the digits run out: it counts 0 to 9 and then a to z, one character per value. Arithmetic uses the browser's big-integer support rather than floating point, so a value such as 18446744073709551616 converts digit for digit instead of arriving rounded, and there is no size at which the result quietly stops being exact.

Left on Auto, the source base comes from the prefix — 0x is hexadecimal, 0b is binary, 0o is octal, a leading # is hexadecimal, and everything else is decimal. That last rule is the one to watch: 1010 on its own is read as one thousand and ten, not as ten, so set From base to Base 2 explicitly when your input carries no prefix. Underscores, spaces and commas are treated as grouping and thrown away, so a European decimal comma disappears with them and 3,14 comes back as 314; only a full stop marks the radix point, and exponent notation such as 1e3 is refused rather than expanded. Each line is converted on its own, and a digit the source base does not have halts the whole run — that character, the value and a line number are quoted back instead of the bad value being skipped and the rest converted. Blank lines are dropped before the counting, so the number you are given is the position in the list rather than the row in your editor.

Fractions are converted rather than discarded at the radix point. The part after the point is held as an exact ratio and expanded one digit at a time in the target base, which is why 0.1 in decimal comes out as 0.000110011001… in binary at the default limit of twelve digits — that expansion never terminates, so it is cut at the Fraction digits setting, which runs from one digit to sixty-four. The trailing ellipsis is there to mark a cut result as cut; a fraction that does terminate is printed without one, so you can always tell an approximation from an exact answer.

Three limits decide whether this is the right tool for the job in front of you. Negative values keep their minus sign, so it will not produce the two's complement pattern a 32-bit register holds for -1. Output has no fixed width, no leading zeros and no grouping, so 5 in binary is 101 and never 00000101. And base 64 in the Base64 sense is not on the list, because that is a byte-encoding scheme rather than a radix — Base64 Encoder Decoder covers it. The conversion itself happens in this browser tab, so nothing you paste is transmitted and the page still works with the network off.

How to use it

  1. Paste your numbers, one per line. Load sample fills the box with a deliberate mix: 255, 0b1101, 0o777, a fraction, a negative and a value past 64 bits.
  2. Set From base, or leave it on Auto. Auto reads a 0x, 0b, 0o or # prefix and treats anything else as decimal. Pick a base from 2 to 36 when the input is bare.
  3. Choose what to convert to. The default prints binary, octal, decimal and hex side by side as a table. Select a single base instead when one column is all you want.
  4. Adjust the fraction limit and the styling. Fraction digits caps a non-terminating expansion between 1 and 64 digits. Uppercase letters is on by default, and 0x / 0b / 0o prefixes are off.

Processing & privacy

Runs on your device. Your file is processed directly in this browser.

Common use cases

Reading values out of a register dump or a hex editor

Paste the 0x values as they were copied. The prefix is recognised without stripping it by hand, and the decimal and binary forms line up beside each one.

Working out a Unix permission mask

File modes are octal. Converting 755 from base 8 to base 2 shows the three-bit groups that sit behind rwxr-xr-x instead of leaving you to recall them.

Explaining why a decimal fraction misbehaves in code

Converting 0.1 to base 2 shows the repeating expansion that floating point has to cut short, which is the whole of the rounding-error story in one line.

Converting an identifier that exceeds 64 bits

A snowflake ID or a large hash is rounded by anything that parses it as an ordinary JavaScript number. Big-integer arithmetic here returns every digit.

Questions

Is anything uploaded?
No. Number Base Converter runs in this browser tab using its built-in big-integer arithmetic, so nothing is transmitted or stored and it keeps converting with the network disconnected.
Why was 1010 treated as a decimal number?
With From base on Auto, a run of plain digits is read as decimal, because that is what most pasted input is. Only 0x, 0b, 0o and a leading # change the source base. Choose Base 2 in From base to force a binary reading.
Can it show a negative number in two's complement?
No. Negatives are written with a minus sign, so -1 in base 2 is -1 rather than a run of ones. Two's complement depends on a fixed register width, and this tool neither asks for a width nor applies one.
What does the ellipsis after a result mean?
It marks a fraction that does not terminate in the target base and was therefore cut at the Fraction digits limit. Raising the limit adds digits, up to sixty-four, and the ellipsis remains while digits are still being dropped.
Why did some results come out with no prefix?
Prefixes are only conventional for binary, octal and hexadecimal. Turn the option on and a base 5 or base 36 result is still printed bare, because there is no standard marker to put in front of it.
How large a number can it handle?
There is no imposed ceiling: integers stay exact at any length, and the practical limit is your device. Long lists are converted in batches so the tab stays responsive and the job can be cancelled part-way.
Does it convert text into binary?
No, it converts numbers between bases. Turning characters into bytes is a different job — Binary Text Converter encodes text as UTF-8 bytes in binary, hex, decimal or octal, and reads them back.

Related tools