Base Converter

Type in any field to convert between bases 2, 8, 10, 16, and any base from 2 to 36, with big numbers, negatives, repeating fractions, and two's complement.

Base

An overline marks the repeating digits. Non-repeating or repeating parts longer than 64 digits are cut off with “…”.

Two's complement

Bit width

How to Use

  1. Type a number into any field and the others update instantly: there's one field each for binary, octal, decimal, and hexadecimal, plus a field for any base from 2 to 36.
  2. Input is case-insensitive. You can include a 0b, 0o, or 0x prefix (it must match the field's base) and separate digits with underscores or spaces, such as 0xFF_FF or 1111 0000, so you can paste numbers straight from code.
  3. Write negative numbers with a minus sign, like -FF. Integers use BigInt, so 64-bit IDs, hash values, and even larger numbers stay exact.
  4. Fractions work too. When a fraction doesn't terminate, the repeating digits are marked with an overline—decimal 0.1 is 0.00̅0̅1̅1̅ in binary. Non-repeating or repeating parts longer than 64 digits are cut off with “…”. You can paste an overlined repeating fraction back into any field for an exact conversion.
  5. The two's complement section offers 8, 16, 32, and 64 bits and shows padded binary and hex. You can also paste hex from a debugger straight into a two's complement field—8-bit FF shows −1 everywhere else. Values outside that width's signed range show an error instead of being silently truncated, and the section is disabled for fractions.
  6. If something's wrong, only the field with the problem shows the character position and reason, while the other fields keep their last good values. “Select the problem” highlights that character. “Clear” empties every field.

Where base conversion shows up in everyday work

Converting between number bases sounds like a classroom exercise, but developers, sysadmins, and designers run into it constantly:

Converting a base only changes how a number is written. The value stays the same, and nothing is hidden, so it is not encryption. It is also a different job from Base64, which encodes arbitrary bytes as text. If you need to turn a file or an image into text, use a Base64 tool instead.

A classic programmer joke makes the point: why do programmers confuse Halloween and Christmas? Because Oct 31 equals Dec 25. Read 31 as an octal number and you get 3 × 8 + 1, which is 25.

A reference table for the first seventeen numbers

If you memorize these rows, most everyday conversions become mental arithmetic:

Decimal Binary Octal Hexadecimal
0 0000 0 0
1 0001 1 1
2 0010 2 2
3 0011 3 3
4 0100 4 4
5 0101 5 5
6 0110 6 6
7 0111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
16 10000 20 10

The pattern is regular. One hexadecimal digit always matches four binary digits, and one octal digit always matches three. A byte has eight bits, so it needs exactly two hex digits, and the largest byte value, FF, is 255. That is why hex is the standard way to write bytes: it is compact, and you can still see the bits underneath.

A few useful landmarks: 255 is FF and 11111111 in binary and 377 in octal. 256 is 100 in hex. 1024 is 400 in hex, and it is 10000000000 in binary, which is a one followed by ten zeros.

Converting by hand

Decimal to another base: divide repeatedly and read the remainders from the bottom up. To write 100 in binary, divide by 2 again and again: 100 gives 50 remainder 0, 50 gives 25 remainder 0, 25 gives 12 remainder 1, 12 gives 6 remainder 0, 6 gives 3 remainder 0, 3 gives 1 remainder 1, and 1 gives 0 remainder 1. Reading the remainders from last to first gives 1100100.

Another base to decimal: multiply each digit by its place value and add. In binary 1100100, the place values from the right are 1, 2, 4, 8, 16, 32, and 64. The ones sit at 4, 32, and 64, which add up to 100. Hexadecimal works the same way, with place values of 1, 16, 256, and so on.

Binary and hex convert directly without passing through decimal. Split the bits into groups of four, starting from the right, and replace each group with one hex digit. For example, 1101 0110 1111 splits into 1101, 0110, and 1111, which are D, 6, and F, so the result is D6F, or 3439 in decimal. Going the other way, expand each hex digit into four bits. Octal uses the same trick with groups of three.

Signed ranges at each bit width

The two’s complement section lets you choose 8, 16, 32, or 64 bits. The width decides which numbers fit, and the table below lists the signed range for each width along with the hex form of −1:

Bit width Minimum Maximum −1 in hex
8 −128 127 FF
16 −32768 32767 FFFF
32 −2147483648 2147483647 FFFFFFFF
64 −9223372036854775808 9223372036854775807 FFFFFFFFFFFFFFFF

At every width, −1 is all ones, which is a quick way to recognize a two’s complement value in a dump.

To work out a negative number by hand, invert the bits and add one. For −5 in 8 bits, start with 5, which is 0000 0101, flip every bit to get 1111 1010, and add one to get 1111 1011, or FB. An equivalent shortcut is to subtract the absolute value from two to the power of the width: 256 − 5 is 251, and 251 is FB in hex.

Why some fractions never finish

Whole numbers always convert to a finite string in any base, but fractions do not. Beyond the well-known 0.1, a few examples build intuition:

You can see this in the tool by typing 0.3 with an overline over the 3 into the decimal field, then setting the custom field to base 3. The overline is a Unicode combining character, and you can copy it straight from the tool’s own output.

What this tool does and does not cover

When your goal is to turn bytes, files, or images into text for transport, a Base64 tool is the right choice. This converter only deals with how a number itself is written.

FAQ

Why doesn't 0.1 convert to a finite binary fraction?

A fraction terminates in a given base only if every prime factor of its reduced denominator divides that base. 0.1 is 1/10, whose denominator has the factors 2 and 5, but binary only has 2, so the 5 never divides out and you get the repeating fraction 0.00̅0̅1̅1̅. That's also why 0.1 + 0.2 isn't exactly 0.3 in most programming languages. This tool works with exact fractions of whole numbers, so it finds the full repeating block instead of showing a rounded approximation.

What is two's complement, and why is FF equal to −1 in 8 bits?

Two's complement is how computers usually store signed integers: the top bit counts as negative 2 to the power of (bits − 1), and the remaining bits add up as usual. In 8 bits, FF is 1111 1111, which is −128 + 127 = −1, and 80 is 1000 0000, which is −128. The same bits mean different numbers at different widths: FF is −1 in 8 bits but 255 in 16 bits. Two's complement only covers integers, so the section is disabled when you enter a fraction.

Why doesn't it just truncate numbers that don't fit the bit width?

Many languages silently drop the high bits on overflow—storing 300 in 8 bits gives 44—and that's a classic source of hard-to-find bugs. This tool shows an error when a value is outside the signed range of the selected width and tells you that range, such as −128 to 127 for 8 bits, so you know you need a wider type instead of getting a plausible-looking wrong answer.

How large a number can it convert? Will it lose precision?

Integers use BigInt, so there's no fixed limit and numbers beyond 2⁵³ or 2⁶⁴ stay exact to the last digit. Converters built on regular JavaScript numbers start losing precision past 2⁵³ (about 9 quadrillion), which breaks 64-bit IDs and hash values. Fractions use exact ratios of BigInts, so there are no floating-point errors either.

What are base 36 and other custom bases used for?

Bases above 10 use letters for digit values of 10 and up—A is 10 and Z is 35—so the largest base is 36. Base 36 is popular for short URLs, order numbers, and codes that need to pack a large number into few characters. Bases like 3, 5, 7, and 12 show up in math and computer science homework.