Free tool · Exact at any size
Number base converter
Binary, octal, decimal, hexadecimal and any base from 2 to 36 — withexact arithmetic, so a 64-bit identifier converts correctly instead of quietly losing its last digit the wayparseInt does.
Hex is just binary in fours
This is the whole reason hexadecimal exists, and once it clicks the conversion needs no arithmetic at all. Sixteen is two to the fourth, soone hex digit is exactly four binary digits — always, with no carrying between them.
So A7 is 1010 0111: A is 1010 and 7 is 0111, read off separately and pushed together. It works in both directions, which is why a byte is always exactly two hex digits and why memory addresses and colour codes are written in hex rather than decimal.
Octal is the same trick with three bits per digit, which is why Unix file permissions are octal: rwx is three bits, so755 is 111 101 101 and each digit is one group's permissions exactly.
Where other converters go wrong
JavaScript numbers are doubles, and a double stores integers exactly only up to 9,007,199,254,740,991 — two to the 53rd, minus one. Past that, the gaps between representable integers are larger than one.
So parseInt("9007199254740993") returns9007199254740992. One out. No error, no warning, no indication that anything was lost — and every converter built the obvious way inherits it.
That is not an edge case for anyone working with real systems. A 64-bit database id, a Twitter-style snowflake id, a hash fragment, a permission mask — all of them live above that line. This page usesBigInt throughout, which is exact at any size, and warns you when you have crossed into the range where the shortcut would have failed.
A check you can run against any converter: enter18446744073709551615, the largest unsigned 64-bit value. The correct hexadecimal is FFFFFFFFFFFFFFFF. If a tool gives you anything else, it is rounding.
What the odd bases are for
- Base 2 — what the hardware actually does. Everything else is a way of writing it that humans can hold in their head.
- Base 8 — three bits a digit. Survives mainly in Unix file permissions.
- Base 16 — four bits a digit, so two digits per byte. Colours, memory addresses, hashes, MAC addresses.
- Base 36 — digits plus the Latin alphabet. The densest you can get with plain alphanumerics and no case sensitivity, which is why it shows up in short ids and URL slugs.
- Base 12 — divides evenly by 2, 3, 4 and 6, which is why so many old measures come in twelves. Mostly of historical interest, and it is in the "another base" box if you want it.
Questions
How do I convert hex to binary by hand?
One hex digit at a time, four bits each. A = 1010, F = 1111. No arithmetic, no carrying. The working is shown above the fold for whatever you enter.
Why did another converter give a different answer?
If the number was above 9,007,199,254,740,991, it was almost certainly rounding — parseInt cannot represent it. Try 18446744073709551615: the right hex answer is FFFFFFFFFFFFFFFF.
Is there a size limit?
No practical one. The arithmetic is BigInt, so a 256-bit hash converts exactly.
More free tools
JSON formatter · Colour contrast checker · Image compressor · Random picker · Password generator
All free, all running entirely in your browser. Built by Maxverse Lab, a software studio in Karachi.