Toolkit
All tools
Bases 2 to 36 · Free

Number Base Converter

Type a number in binary, octal, decimal, hexadecimal, or any base up to 36, and read it in all the others at once. Exact big-integer arithmetic, real fraction conversion, and the bit pattern it would take in a register.

Exact BigInt maths in your browser · Nothing uploaded

255 in base 10 is 255 in decimal.

Value to convert

Type it in the base you already have

Spaces, underscores, and commas are ignored, so a grouped value pastes straight in. A matching 0b, 0o, or 0x prefix is accepted too.

Same number, other bases

255 in decimal

Binary · base 2
0b1111 1111
Octal · base 8
0o377
Decimal · base 10
255
Hexadecimal · base 16
0xff
Base 36 · base 36
73
8 bits wide8 bits set
In a register

Two’s complement at 8 bits

Bit pattern
1111 1111
Unsigned
255
Signed
-1
Hex
0xFF

This fits 8 bits unsigned, but read as signed it is -1, because the top bit is set.

The working

Each digit multiplied by its place value

A number in any base is a sum: the digit times the base raised to the position, counting from zero on the right. This is that sum for the integer part, in base 10.

Digit, place value, and contribution for each digit of the integer part
DigitWorthPlaceContributes
22102200
5510150
551005
Those contributions add up to 255 in decimal.
Every base at once

Base 2 through base 36

Thirty-five ways to write the same quantity. Notice how the digit count falls as the base rises: that relationship is a logarithm, and it is the whole reason hexadecimal exists.

The same value written in every base from 2 to 36
BaseValueDigits
2111111118
31001106
433334
520104
611034
75133
83773
93133
10Yours2553
112123
121933
131683
141433
151203
16ff2
17f02
18e32
19d82
20cf2
21c32
22bd2
23b22
24af2
25a52
269l2
279c2
28932
298n2
308f2
31872
327v2
337o2
347h2
357a2
36732
How it works

One quantity, thirty-five ways to write it down.

A base is only a choice of how many symbols to count with before carrying. The quantity 255 does not change when it is written as 11111111, 377, or FF; only the notation does. Converting is therefore repeated division by the target base for the integer part, and repeated multiplication for the fraction, and both are done here on exact integers rather than on floating-point numbers. That distinction is the whole engineering content of this tool: it is why a nineteen-digit identifier survives the round trip intact, and why a decimal fraction that cannot be written in binary is reported as repeating rather than quietly rounded to something that looks tidy and is wrong.

  1. 01

    Type the number and say which base it is in

    Binary, octal, decimal, and hex are one tap away, and any base from 2 to 36 can be typed in. Spaces, underscores, and commas are ignored, so a grouped value pastes straight from a hex dump or a spreadsheet. A matching 0b, 0o, or 0x prefix is accepted and stripped.

  2. 02

    Read it in every other base at once

    The four common bases plus one target of your choosing update as you type, each one copyable on its own. Below them, the same value written in all thirty-five bases from 2 to 36, so the shrinking digit count is visible rather than described.

  3. 03

    Check the bit pattern and the working

    The register panel shows how the integer would sit in 8, 16, 32, or 64 bits, with the signed and unsigned readings side by side. The working panel breaks the number into digit times base to the power of position, which is the definition of positional notation and the fastest way to check a conversion by hand.

For firmware, colour codes, permissions, and homework

Exact arithmetic, honest fractions, and the register view.

Exact past the floating-point cliff

Every conversion is BigInt arithmetic. A converter built on ordinary JavaScript numbers is quietly wrong above 9,007,199,254,740,992: ask it about 9007199254740993 and it hands back the even number below. That is exactly the sort of value people paste from a database id or a debugger, so this one carries it exactly, in any base, at any length up to 512 characters.

Fractions converted by division, not by rounding

A fractional part is held as an exact numerator over base to the power of its digit count, then converted by repeated multiply and divide. So 0.1 in decimal comes out as 0.0001100110011… in binary and is labelled as repeating rather than silently rounded, which is the clearest demonstration of why 0.1 plus 0.2 is not 0.3 in most languages.

Two's complement, including the overflow

Pick 8, 16, 32, or 64 bits and see the stored pattern, the unsigned reading, and the signed reading together. A value too large for the width is wrapped rather than refused, because wrapping is what the register does, and seeing 300 become 44 in a byte is usually the reason the converter was opened.

Errors that name the digit and the position

Type 9 in an octal number and the message says that 9 is worth nine, that base 8 stops at 7, and points at the character with a caret under it. A converter that just clears the output leaves you hunting for the typo yourself.

Grouping that matches the base

Four-bit and eight-bit blocks for binary and hex, thousands separators for decimal, and neither applied where it makes no sense. Grouped output copies exactly as displayed, with the 0b, 0o, and 0x prefixes on or off depending on whether it is going into prose or into source code.

All thirty-five bases in one table

Base 2 to base 36, with the digit count beside each one. It makes the logarithmic relationship obvious: a byte needs 8 binary digits, 3 decimal, and 2 hex, which is precisely why hexadecimal became the shorthand for binary rather than octal.

Base questions

Hand conversion, hex letters, two's complement, and why 0.1 misbehaves.

How do I convert binary to decimal by hand?+

Multiply each digit by two raised to its position, counting from zero at the right, then add the results. For 1011 that is 1×8 + 0×4 + 1×2 + 1×1, which is 11. The doubling method is quicker for long values: start at the leftmost digit, then repeatedly double the running total and add the next digit. For 1011 that runs 1, then 2+0 = 2, then 4+1 = 5, then 10+1 = 11. The working panel on this page lays out the first method digit by digit, so you can check your own arithmetic against it.

Why does hexadecimal use letters?+

Because base 16 needs sixteen distinct digits and the decimal system only supplies ten. A through F fill the gap, standing for ten through fifteen. The reason to want sixteen in the first place is that 16 is 2 to the fourth power, so exactly four binary digits map to one hex digit with no remainder and no carrying between them. A byte is therefore always two hex characters, which is why memory dumps, colour codes, and MAC addresses are all written that way. Octal has the same property with three bits per digit, and it lost to hex mainly because bytes are eight bits rather than nine.

What is two's complement, and why not just use a sign bit?+

Two's complement stores a negative number as the pattern that, added to its positive counterpart, wraps the register back to zero. In eight bits, negative one is 11111111, because 11111111 plus 00000001 overflows to 00000000. The reason to prefer it over a plain sign bit is that addition and subtraction then need no special cases: the same adder circuit handles both signs, and comparison still works. A sign-magnitude representation also produces two zeros, positive and negative, which every piece of code then has to remember to handle.

Why is 0.1 not exact in binary?+

For the same reason a third is not exact in decimal. A fraction terminates in a given base only when the denominator's prime factors all divide that base. Ten factors into two and five, so tenths, fifths, and halves all terminate in decimal. Two has only itself, so a binary fraction terminates only when the denominator is a power of two. A tenth is not, so 0.1 becomes 0.000110011001100… repeating forever, and any fixed-width format has to cut it somewhere. That truncation is what makes 0.1 plus 0.2 come out as 0.30000000000000004 in most languages. Type 0.1 here with decimal as the source base and the binary row shows the repetition directly.

What is base 36 for?+

It is the largest base that fits in the digits 0 to 9 plus the twenty-six letters of the Latin alphabet, so it is the densest way of writing a number that is still case-insensitive and typeable. That makes it useful for short identifiers and URL slugs: a value that needs ten decimal digits fits in six base-36 characters. Base 32 is often preferred in practice because it drops the visually confusing characters and maps cleanly onto five bits, and base 62 goes further by making letter case significant, at the cost of identifiers that cannot be dictated over a phone.

Can I convert a negative number?+

Yes. Type a leading minus and every base shows the same sign, since a minus sign is a property of the value rather than of the notation. The register panel is where it gets interesting, because a fixed-width register has no sign character: it stores the two's complement pattern instead, so negative 42 in eight bits is 11010110, which read as unsigned is 214. Both readings are shown together, along with a note explaining which one your language will give you depending on whether the type is signed.

What happens if my number is too big for the chosen width?+

It wraps, and the page says so. Three hundred does not fit in eight bits, so the register holds 44, which is 300 minus 256. That is not an error in the converter, it is what the hardware does, and reproducing it is more useful than refusing to answer. The conversions above the register panel are unaffected: those are exact and unbounded, up to the 512-character input ceiling.

Does the converter accept 0x and 0b prefixes?+

Yes, when the prefix matches the base you have selected. 0x1F in a box set to hexadecimal reads as 31; the same string with the base set to binary is a genuine mismatch, so the x is reported as an invalid digit rather than being quietly ignored. Output prefixes are a separate switch: turn them on when the value is going into source code, off when it is going into prose or a spreadsheet cell.

Why do the digits get fewer as the base gets bigger?+

Because the digit count is a logarithm. Writing a number n in base b takes about log base b of n digits, so raising the base lowers the count, but only slowly: doubling the base saves you a single digit per binary digit's worth of growth. That is why 255 needs eight binary digits, three decimal digits, and two hex digits, and why the all-bases table on this page shrinks quickly from base 2 to base 10 and then barely changes from base 20 to base 36.

Is anything sent to a server?+

No. All the arithmetic runs in this tab in JavaScript's built-in BigInt, and there is no request involved in a conversion. Values pasted from a debugger, an internal id, or a private key fingerprint stay on your machine.

More focused tools, ready when you are.

Explore the growing collection for calculations, documents, writing, and everyday work.

Browse all tools