Number Base Converter
Convert decimal, hex, binary and octal live in four linked boxes, with a custom base and two's complement.
This number base converter gives you four linked boxes, one number. Type into the decimal, hex, binary or octal field and the other three update live as you type, no convert button to press. The math runs on JavaScript BigInt, so a 200-digit integer converts just as exactly as 255 does, with no rounding and no silent precision loss. Prefixes 0x, 0b and 0o are accepted, and spaces or underscores inside a number are ignored. A custom base field handles any base from 2 to 36, and the two's complement view shows how a CPU would store your value as a signed 8, 16, 32 or 64-bit integer, flagging anything that does not fit instead of wrapping it silently. Whole integers only, and nothing you type ever leaves the page.
100% in your browser. Nothing you type ever leaves this page.
Local number base utility
Four boxes, one number. Type into any of them, decimal, hex, binary or octal, and the other three follow along live as you type. The math runs on BigInt, so a 200-digit monster converts just as exactly as 255 does, no rounding, no silent precision loss. I built this after one too many packet captures where I did hex to binary in my head and landed exactly one nibble off.
Everything runs in your browser, nothing leaves the page. Prefixes 0x, 0b and 0o are accepted, and spaces or underscores inside a number (like 1_000_000) are ignored. Whole integers only, this is a base converter, not a float playground.
This field is linked too. Type here and the four main boxes update, or change the base and watch the same number get respelled. Base 36 uses digits 0 to 9 then A to Z.
This shows how a CPU would store your number as a signed integer of the chosen width. Negative values get 2^n added (that is the whole trick), and anything outside the signed range is flagged instead of silently wrapped.
How positional bases actually work
A number base converter only makes sense once you see that a base is just an agreement about what each column is worth. In decimal the columns are worth 1, 10, 100 and so on, each one ten times the last. Write 2026 and you're really saying two thousands, no hundreds, two tens, six ones. That's it. That's the entire system, and you've been using it since primary school without anyone calling it positional notation.
Every other base plays the same game with a different multiplier. Binary columns double as you move left, hex columns multiply by sixteen. So 0xFF means fifteen sixteens plus fifteen ones, which lands on 255. Once that clicks, converting between bases stops being magic and turns into bookkeeping. Tedious bookkeeping. Which is honestly the whole reason this page exists.
Why hex maps onto binary so cleanly
Sixteen is two to the fourth power, and that single fact does all the work. Each hex digit corresponds to exactly four bits, a nibble, so converting between hex and binary needs no arithmetic at all. It's a sixteen-row lookup table. F is always 1111. A is always 1010, wherever it sits in the number. You can convert a 64-character hash by eye, one digit at a time, and never carry anything.
Octal almost pulled the same trick with groups of three bits, and on old 36-bit machines it genuinely worked. Then the byte settled at 8 bits, and 8 doesn't split into threes. Hex eats a byte in exactly two digits. That's pretty much the entire story of why your debugger shows hex and not octal.
Two's complement, explained honestly
Most explanations make it sound like a clever trick. It isn't, it's modular arithmetic wearing a trench coat. In 8 bits there are only 256 possible patterns, so the convention says: patterns 0 to 127 mean themselves, and patterns 128 to 255 mean the value minus 256. So 11111111 reads as 255 unsigned but -1 signed. Same bits, different reading glasses.
The payoff is that the CPU's adder never needs to know about signs. Addition works identically on signed and unsigned values, so the hardware stays dumb and fast. The cost is two famous gotchas. The range is lopsided (8-bit signed runs -128 to 127, there's no +128), and overflow wraps around without a sound. The view in this tool flags values that don't fit instead of wrapping them, because silent wraparound is how off-by-billions bugs are born.
Where each base shows up day to day
- Octal: Unix file permissions, basically. Each digit of chmod 644 packs one group's rwx bits, owner first. Outside of permissions and the odd escape sequence, octal is nearly extinct.
- Hexadecimal: everywhere bytes are shown to humans. CSS colors like #1f2937 are two hex digits per channel, MAC addresses, memory dumps, hashes. If a tool prints raw bytes, it prints them in hex.
- Binary: subnet masks make no sense until you look at them in binary. 255.255.255.0 is 24 ones followed by 8 zeros, and that's all a /24 means.
- Decimal: everything aimed at people. Ports, TTLs, exit codes. We count on our fingers and it shows.
Frequently asked questions
How big a number can this converter handle?
Stupidly big. The math runs on JavaScript's BigInt, so there's no 53-bit ceiling like a regular Number has. Paste a 500-digit integer if you want. The conversion stays exact down to the last digit, and the only real limit is your patience scrolling the binary output.
Why does my input get rejected?
Every base only owns certain digits. Binary gets 0 and 1, octal stops at 7, hex adds A through F on top of the usual ten. Type an 8 into the octal box and the error names the exact character that broke. Spaces and underscores are fine though, I strip those before parsing.
What do the 0x, 0b and 0o prefixes mean?
They're spelling conventions from programming languages. 0x announces hexadecimal, 0b binary, 0o octal. You'll meet them in C, Python, JavaScript and most modern languages. The tool accepts them so you can paste straight out of code without trimming anything first.
How does the two's complement view work?
Pick a width (8, 16, 32 or 64 bits) and it shows how a CPU would store your number in exactly that many bits. For negatives it adds 2^n to the value, which is literally what two's complement means. If the number doesn't fit the chosen width, it tells you so instead of silently wrapping.
Does my number get sent anywhere?
No. There's no server doing the math, it's all JavaScript running on your machine. You can load this page, pull your network cable and keep converting all afternoon. Nothing gets logged, nothing leaves the browser.