The same quantity looks entirely different depending on its base. Decimal 255 is 11111111 in binary and ff in hexadecimal. Colour codes, file permissions, bit flags and memory addresses all conventionally use different bases, so converting between them is routine work.
This tool converts across bases 2 through 36 and computes with BigInt. Ordinary JavaScript numbers lose precision past 2^53 and start returning quietly wrong answers for 64-bit integers or long hash values; BigInt has no digit limit, so results stay exact however large the input.
How to use
- Set the input base — Pick base 2, 8, 10 or 16 directly, or choose something else — base 3, base 36 — from the dropdown. Prefixes like
0x,0band0oare stripped automatically, and underscores or spaces used for readability are ignored. - Enter a value — Results in the four main bases appear immediately. If the input contains a digit that does not exist in the chosen base — a
2in binary, say — the problem is reported below the field. - Group the digits — Turn on group digits to break binary into groups of four and hex into pairs.
1111 1111reads far more easily than11111111, and pairs make it straightforward to count hex by byte. Copying still gives you the ungrouped value. - Check type fit and bitwise results — Badges show which integer types the value fits into — useful when choosing a database column or checking for overflow. The bitwise panel below computes AND, OR, XOR and shifts, showing the result in decimal, hex and binary together.
Frequently asked questions
Why does programming use hexadecimal so much?
Because 16 is 2^4, so one hex digit maps exactly onto four binary digits. Conversion needs no arithmetic, just substitution — see ff and you immediately know it is 1111 1111.
That also means one byte is always exactly two hex characters. It is why colour codes like #FF5733 are one byte each for red, green and blue, and why memory addresses and hash digests are printed in hex. In decimal, byte boundaries would not line up with digit positions at all.
My result differs from another converter for large numbers.
The other tool is probably computing with ordinary JavaScript numbers. Number is a double-precision float, so integers above 2^53 (9,007,199,254,740,992) cannot be represented exactly and get rounded to the nearest representable value.
This tool uses BigInt, so it stays exact at any size. When results diverge on 64-bit IDs, long hashes or large bitmasks, this is the one to trust.
How are negative numbers handled?
Enter a leading - and the sign is carried through to every base, which is mathematically correct.
Memory does not work that way, though — there is no minus sign stored, only a two's complement bit pattern. That is why a negative input also displays its actual 8-, 16- and 32-bit representations. −1 in eight bits is 1111 1111. You need that view when debugging low-level code or picking apart a binary protocol.
Why go all the way up to base 36?
Ten digits plus twenty-six letters is 36, the largest base available without distinguishing letter case. JavaScript's own toString(36) stops there for the same reason.
In practice it is used to shorten identifiers. Converting a large number to base 36 cuts its length considerably — a timestamp comes out around eight characters. That makes it a handy technique for URL shorteners or order numbers where you want something compact but still human-readable.
Concepts worth knowing
Two's complement removes the need for subtraction
Computers store negatives in two's complement so that no separate subtraction circuit is required. In eight bits, −1 is 1111 1111; add 1 and you get 1 0000 0000, the ninth bit falls off the end, and you are left with 0000 0000. One adder handles both operations.
It has a side effect: the range is asymmetric, so int8 runs from −128 to 127. Negating −128 gives 128, which does not fit, so it wraps back to −128 — the source of a well-known family of overflow bugs.
Bit flags and masking
Packing many true/false settings into a single integer: assign each bit a meaning, set with OR, test with AND, toggle with XOR. Unix file permissions are the canonical example, where each octal digit of 755 combines read (4), write (2) and execute (1).
Databases use the same trick for things like user permissions — one column holds 32 settings and comparisons stay fast. The cost is that nobody can tell later what bit 12 meant, so reserve it for small, stable sets of flags.
Shifts and multiplication
A left shift x << n multiplies by 2^n and a right shift divides, exactly as moving digits in decimal multiplies by ten.
Shifting used to be a meaningful optimisation because it was faster than multiplying, but compilers now turn x * 8 into a shift on their own. Writing shifts for speed only obscures intent. Use them when manipulating bits is the actual point — moving a flag into position, assembling bytes — not as a stand-in for arithmetic.