Number Base Converter
Binary, octal, decimal and hex side by side, plus any base from 2 to 36.
Updated
Spaces, underscores and commas are ignored, so you can paste a grouped value straight in. A leading minus sign is kept.
Any base from 2 to 36. Above base 10 the digits continue into the letters, so base 36 runs 0 to 9 then a to z.
The same value, five ways
1111 1111
377
255
FF
73
- Bits
- 8
- Bytes to hold it
- 1
- Hex digits
- 2
One hexadecimal digit is exactly four binary digits, which is why the binary column groups in fours and lines up with the hex column digit for digit. Octal groups in threes for the same reason.
In short
Why does a 64-bit hex value need BigInt to convert correctly?
Because a JavaScript number is an IEEE 754 double with 53 bits of significand, and 0xFFFFFFFFFFFFFFFF needs 64. Sent through a double it returns 18446744073709551616, one more than the true 18446744073709551615, and nothing warns you. This converter uses BigInt throughout, so all 20 digits survive exactly.
The panel flags the moment a value passes 9007199254740991, the largest integer an ordinary JavaScript number can represent without rounding.
How to use the number base converter
Paste a value, tell the tool which base it is written in, and every other base appears at once. The conversion is exact at any size, because the arithmetic runs on BigInt rather than on ordinary numbers, and there is a copy button on each row so you can take just the form you need.
The reason all four bases appear together is that base questions are almost always comparisons. You are checking whether 0xFF and 255 are the same value, or which bits a mask actually sets, or whether a permission octet matches the binary you expected. Showing one answer at a time makes you do that comparison in your head.
11111111
Binary
eight bits, all set
FF
Hexadecimal
two digits, one byte
255
Decimal
the value the tool opens on
Hexadecimal earns its place because 16 is 2 to the power of 4, so one hex digit is exactly four binary digits and the two notations line up column for column. FF is 1111 1111, and B4 is 1011 0100. Nothing has to be calculated, only looked up, which is why hex is the shorthand for binary everywhere.
Octal works the same way one rung down, since 8 is 2 to the power of 3 and one octal digit is exactly three bits. That is why Unix file permissions are octal: three bits for read, write and execute is one digit per user class, so 755 is 111 101 101 and reads straight off the number.
The same care applies to the input side. parseInt stops at the first character it does not recognise and returns whatever it managed to read, so parsing 12G4 as hexadecimal gives 18 rather than an error. This tool names the offending character instead, because a value with a typo in it is a question, not a number.
Do
- Group binary in nibbles so each group of four lines up with one hex digit.
- Use hex for bit masks and octal for Unix permission bits.
- Check the bit count before storing a value in a fixed width field.
- Prefix hex with 0x and binary with 0b in code so the base is never ambiguous.
- Reach for base 32 or base 36 when you want a short human-typeable identifier.
Don't
- Convert a value over 53 bits through an ordinary floating point number.
- Assume a bare string of digits is decimal when it came out of a config file.
- Read a leading zero as decoration, since some languages parse it as octal.
- Mix uppercase and lowercase hex within one file or one column.
- Confuse a count of bits with a count of bytes when sizing a field.
Values worth recognising across the four common bases, with the bit width each one occupies.
| Binary | Octal | Decimal | Hexadecimal | Bits |
|---|---|---|---|---|
| 1010 | 12 | 10 | A | 4 |
| 10000 | 20 | 16 | 10 | 5 |
| 1111111 | 177 | 127 | 7F | 7 |
| 10000000 | 200 | 128 | 80 | 8 |
| 11111111 | 377 | 255 | FF | 8 |
| 1111101000 | 1750 | 1000 | 3E8 | 10 |
| 10000000000 | 2000 | 1024 | 400 | 11 |
| 1000000000000 | 10000 | 4096 | 1000 | 13 |
| 1111111111111111 | 177777 | 65535 | FFFF | 16 |
| 10000000000000000 | 200000 | 65536 | 10000 | 17 |
Why every colour on the web is written in hex
A screen colour is three independent channels, red, green and blue, and each one is stored in a single byte with 256 possible levels. One byte is exactly two hex digits, so three bytes is exactly six, and that is the whole explanation for the six-character colour codes CSS has used since the beginning.
- FF, the red channel
- 255, fully on
- 88, the green channel
- 136, a little over half
- 00, the blue channel
- 0, fully off
- The whole value as one number
- 16746496 decimal, 24 bits
Each pair is one byte, which is why the six-digit form splits so cleanly and the decimal form does not split at all.
Try that split in decimal and the reason becomes obvious. The same colour is 16746496, and there is no way to see the three channels in it without dividing twice. In hex you read the pairs straight off the string, which is why designers and developers both learned to think in FF and 88 rather than 255 and 136.
The three-digit shorthand follows from the same arithmetic. CSS expands #F80 to #FF8800 by doubling each digit, so it can only express the 16 levels per channel where both digits match. It is a convenience for round numbers rather than a compressed format, and it cannot describe 136 at all.
Alpha is simply a fourth byte on the end, so #FF8800CC adds an opacity of 204 out of 255. The ordering is the thing to watch, because some platforms and file formats put alpha first instead, and a colour that comes out inexplicably transparent is usually an ARGB value being read as RGBA.
The 1000 against 1024 problem, in one paragraph
Memory is addressed in powers of two, so 1024 rather than 1000 is the natural step, and early computing borrowed the metric kilo prefix for it anyway. That borrowing is the entire source of the confusion, because a kilobyte then meant 1024 bytes to a programmer and 1000 bytes to everyone who had ever used the prefix before.
“The prefixes kibi, mebi and gibi denote the binary multiples 1024, 1024 squared and 1024 cubed, distinguishing them from the decimal SI prefixes kilo, mega and giga.”
The standard fix has existed since 1998 and is now IEC 80000-13: kibibyte, mebibyte and gibibyte for the binary multiples, leaving kilo, mega and giga to mean exactly what they mean everywhere else in science. Adoption is uneven, which is why a drive sold as 500 GB shows up as roughly 465 GiB once formatted.
The base arithmetic behind it is visible in this tool. 1024 is 400 in hex and takes 11 bits, 4096 is 1000 in hex and takes 13, and 65536 is 10000 in hex and takes 17. Every one of them is a clean round number in hex and an awkward one in decimal, which is the whole reason the binary sizes stuck.
Converting storage sizes properly
The decimal against binary prefix mess deserves its own page rather than a footnote here. The megabyte to gigabyte converter handles both conventions and shows where the missing space went.
Open the MB to GB converter →The formula, worked line by line
A positional number system is one rule applied repeatedly: each digit is multiplied by the base raised to the power of its position, counting from zero on the right, and the results are added. Decimal is that rule with a base of 10, and every other base is the same rule with a different multiplier.
Conversion between two bases is therefore two passes rather than one clever step. Read the input into an exact magnitude using the source base, then write that magnitude out by repeatedly dividing by the target base and collecting the remainders. Nothing about the value changes in between, only its spelling.
value = sum of digit[i] x base^i, counting positions from zero on the right
to write in a base: divide repeatedly, collect remainders, read them bottom to top
digits above 9 continue into letters, so base 36 runs 0 to 9 then a to z
one hex digit = 4 bits because 16 = 2^4
one octal digit = 3 bits because 8 = 2^3- B in position 1
- 11 x 16 = 176
- 4 in position 0
- 4 x 1 = 4
- As binary nibbles
- 1011 0100
- As octal
- 264
- Decimal
- 180
The binary line is the one worth staring at. B is 1011 and 4 is 0100, so the two nibbles simply sit next to each other with nothing carried between them.
That nibble alignment only works because 16 is a power of two. Decimal is not, so there is no group of bits that corresponds to one decimal digit, and converting between decimal and binary genuinely requires arithmetic rather than a lookup. It is the reason hex exists as a notation at all.
The exactness is the other half of the story. IEEE 754 double precision, the format an ordinary JavaScript number uses, carries a 53-bit significand, so every integer up to 9007199254740991 is exact and beyond that the gaps start. The first casualty is 2 to the power of 53 plus 1, which cannot be represented and silently becomes 2 to the power of 53.
Base 36 is where the digit alphabet runs out, since 10 numerals plus 26 letters is 36 symbols and there is no agreed thirty-seventh. That is also why base 36 shows up in short identifiers: it packs the most value into each character that a case-insensitive alphanumeric string can carry.
Questions people ask
Sources
Where the constants and formulas on this page come from. Each line names the figure it backs.
The binary prefixes kibi, mebi and gibi denote 2 to the 10th, 20th and 30th, and are deliberately distinct from the decimal kilo, mega and giga.
Each hex pair in a six-digit colour is one channel, and the three-digit shorthand expands by duplicating each digit.
CSS Color Module Level 4 — W3C
Related guides
Putting JSON in a URL: Validate, Minify, Percent-Encode, or Base64url?
A decision guide for flattening, encoding, checking, and safely transporting JSON in a query string.
August 11, 2026 · 9 min read
How Many Grams in a Cup? Every Ingredient, One Chart
One formula, fourteen densities. Why flour is 120 g, honey is 340 g, and the ingredient — not the cup — decides the number.
August 10, 2026 · 14 min read
How Are Loan Payments Calculated? Amortization, Explained
One level payment, front-loaded interest — the formula worked by hand, the two levers you control, and why the smaller payment is often the costlier loan.
July 23, 2026 · 13 min read