Number Base Converter
One value, all four bases, plus the arithmetic — live as you type.
Digits 0–1, optional 0b prefix. Spaces, commas and underscores ignored.
1010base 2
4 bits · 1 byte
10101210Avalue = Σ digitᵢ × baseⁱ, counting i from 0 at the rightmost digit
Integers only. Division returns the quotient truncated toward zero. Parsing is arbitrary precision, so nothing wraps at 32 or 64 bits and a negative is written with a sign rather than in two’s complement.
How it works
Pick the base your value is written in — binary, octal, decimal or hex.
Type the value. A 0b, 0o or 0x prefix is stripped, and spaces, commas and underscores are ignored.
Read it back in all four bases at once, each with its own copy button.
Switch to Calculate for a second operand and +, −, × or ÷. The result appears in all four bases too.
Positional notation
A number written in base b is the sum of each digit multiplied by b raised to its position, counting from zero at the rightmost digit. Changing base changes how the value is written down; it never changes the value. That is why 1010, 12, 10 and A are four spellings of one number and not four numbers.
1010₂ = 1·2³ + 0·2² + 1·2¹ + 0·2⁰ = 10₁₀ = 12₈ = A₁₆
Use cases
Binary calculator
Add, subtract, multiply and divide in base 2 without dropping to decimal and back. Set the input base to BIN, switch to Calculate, and the answer comes back in binary with the decimal working shown beside it — which is the line you check when a carry looks wrong.
Hex calculator
Address arithmetic is base-16 addition: 0x1000 + 0x40 = 0x1040. Struct offsets, memory-map boundaries and register banks are all documented in hex, and converting to decimal to do the sum is where the off-by-one comes from. Do it in hex and read the decimal only as a check.
Binary to decimal
11010₂ = 26, 1111111₂ = 127. Each position is a power of two, so the value is just the sum of the powers where a 1 sits. Typing the binary here shows the decimal immediately and the bit count with it, which is the fast way to confirm a mask is the width you meant.
Decimal to hex
255 → FF, 4096 → 1000, 65535 → FFFF. Byte boundaries and colour channels are stated in decimal by designers and consumed in hex by code, and the round numbers in one base are almost never round in the other — 1000 decimal is 3E8, not a boundary of anything.
Hex to binary
FF → 11111111. Hardware registers are documented in hex and read as bit fields, so a datasheet value like 0x2C only means something once it is 00101100 and you can point at bit 5. One hex digit is exactly four bits, which is why the mapping is a substitution rather than arithmetic.
Octal
Unix file modes are the last common use: 0o755 is 111 101 101, three bits per digit, mapping exactly onto rwx for owner, group and other. That exact three-bit alignment is the whole reason octal exists in the toolchain, and it is why 644 and 755 are typed rather than 420 and 493.
Hex colour channels
#FF5733 is three byte values in a row: FF, 57, 33 — 255, 87 and 51 in decimal. Convert one pair at a time to move between a hex colour and an rgb() call, or to see why FF is the ceiling of a channel rather than an arbitrary maximum.
Subnet masks in binary
A /26 mask is 255.255.255.192, and the last octet in binary is 11000000 — two network bits, six host bits, 62 usable addresses. Converting the octet is faster than remembering the table, and it shows the boundary rather than asserting it.
Reading a hex dump
A dump gives you bytes in hex and a file format spec that talks in decimal lengths and bit flags. Converting a field both ways — to decimal to read a length, to binary to read the flags — is most of what makes a dump legible.
Questions
- Which digits are valid in each base?
- 0–1 for binary, 0–7 for octal, 0–9 for decimal, and 0–9 plus A–F for hex. Case does not matter. Spaces, commas and underscores are stripped before parsing, so 1010 1101 and 1010_1101 both work.
- Can I paste a 0x, 0o or 0b prefix?
- Yes. The prefix belonging to the selected base is removed automatically, so 0xFF in hex mode and FF in hex mode are the same input.
- How large a number can it handle?
- Any size. Parsing uses BigInt, so a 256-bit hash converts exactly. Converters built on JavaScript numbers lose precision above 9,007,199,254,740,991 and round silently — 0xFFFFFFFFFFFFFFFF comes back wrong with no warning that anything happened.
- Does it handle fractions?
- No. Integers only, in every base. Division returns the integer quotient truncated toward zero, so 1011₂ ÷ 10₂ is 101₂ and not 101.1₂.
- Does it do two’s complement?
- No. A leading minus is carried through as a sign, so −5 shows as −101 in binary rather than as a fixed-width 11111011. Two’s complement needs a width, and there is no way to know whether you meant 8, 16, 32 or 64 bits.
- Is anything sent to a server?
- No. The whole thing runs in your browser. Nothing is uploaded, logged or stored.
More tools
One of 18 free tools here. They come out of building utility apps for macOS, iOS and the browser — all of it by one person.
See the apps