Convert
Convert between number bases
Type in any base and read the other three simultaneously. Uses big-integer arithmetic, so a 64-bit identifier converts exactly instead of turning into 9.2e18.
How to use it
- Type the number in the input box.
- Pick the base it is written in.
- Read binary, octal, decimal and hexadecimal below.
- Prefixes such as 0x or 0b are tolerated and stripped.
Why hexadecimal sits between humans and machines
Binary is what the hardware sees, but writing 32 bits as zeros and ones is unreadable and error-prone. Hexadecimal works because 16 is a power of two: each hex digit maps to exactly four bits, so a byte is always two characters and no arithmetic is needed to translate. That alignment is the entire reason hex won over decimal for memory addresses, colour codes and byte dumps.
Negative numbers and two's complement
Computers do not store a minus sign. Negative integers are represented as two's complement: invert every bit and add one. This makes subtraction the same circuit as addition, which is why it is universal. The consequence for conversions is that 0xFFFFFFFF is 4294967295 as an unsigned 32-bit value and -1 as a signed one — the bits are identical, the interpretation is not.
Reading a bitmask in hex
Permissions, feature flags and status codes are usually written in hex because each hex digit maps cleanly to four bits. 0x1F is 0001 1111: five flags set, three clear. Reading that from the decimal 31 is impossible; reading it from hex takes a second. This is the whole reason the format survives in low-level code.
When a value is larger than 253, JavaScript has already lost precision before any conversion runs, so a 64-bit flag set will not round-trip. Convert such values as strings, or in a tool that uses arbitrary-precision integers.
Frequently asked questions
Why not use parseInt?
JavaScript numbers are doubles and lose precision above 2^53. This tool converts through BigInt, so a full 64-bit value like 18446744073709551615 comes out exact rather than rounded.
Which characters are accepted?
Whatever the selected base allows — 0-1, 0-7, 0-9 or 0-9a-f. Anything outside the base is reported with the offending character instead of silently returning NaN.
Does it handle negative numbers?
Not currently; the input is treated as unsigned. For two's-complement work, convert the magnitude and apply the sign yourself.
Can I paste a hex colour?
Yes — set the base to 16 and paste the six digits without the hash. The decimal value is the colour as an integer.
Why does my 19-digit number come back wrong?
It exceeds 253, the largest integer JavaScript represents exactly. Convert such values as strings, or in a runtime with 64-bit integers.
What do the 0x, 0b and 0o prefixes mean?
Hex, binary and octal respectively. Many parsers accept them; JSON does not, so strip the prefix before putting a number into JSON.