Base Converter
Convert numbers between binary, octal, decimal, and hexadecimal — all four representations live side by side, and editing any field updates the others instantly. Built for programmers debugging bit fields, students learning number systems, and anyone who's ever needed to know what 0xDEADBEEF is in decimal (3,735,928,559).
How to use the base converter
- Type into any field. The Decimal field is most familiar, but if you have a hex value (say, from a memory dump), paste it straight into the Hex field — Decimal, Binary, and Octal update at the same instant.
- Paste with prefixes. The tool understands
0xon hex,0bon binary, and0oon octal — strip nothing, paste the literal as your code has it. - Toggle formatting. Uppercase hex (FF vs ff), digit grouping (1111 1111 vs 11111111), and prefix display are all opt-in switches. Defaults match what most code prefers.
- Quick values. One-click presets for common boundaries: 255 (uint8 max), 65535 (uint16 max), 4294967295 (uint32 max), and 16M (24-bit RGB).
Why four bases?
- Binary (base 2)
- The native language of digital electronics. Each digit is one bit; 8 bits = one byte. Used directly when working with bitmasks, network packet flags, or low-level CPU registers.
- Octal (base 8)
- Each octal digit represents 3 binary bits. Mostly historical now, but still appears in Unix file permissions (
chmod 755is octal — rwxr-xr-x) and some legacy system documentation. - Decimal (base 10)
- Human-default — what you'd write on a grocery list. The lingua franca for non-technical contexts; converters are usually anchored here.
- Hexadecimal (base 16)
- The programmer's compact view of binary. Each hex digit is 4 bits (a 'nibble'), so a byte fits in 2 digits. Used for memory addresses, colour codes, hash digests, and pretty much anything that wants bit-aligned readability.
Worked examples
- 255 (decimal) =
11111111binary =377octal =FFhex. The largest value that fits in a single 8-bit byte (uint8). - 1024 =
10000000000binary =2000octal =400hex. The classic 1 KB boundary. - 4,294,967,295 =
11111111 11111111 11111111 11111111binary =FFFFFFFFhex. The largest 32-bit unsigned integer — also the value of-1reinterpreted as uint32 in two's complement. - 0xDEADBEEF = 3,735,928,559 decimal. A classic 'magic number' used as a sentinel in debug builds because it's memorable in hex.
Conversion formulas
- From base N to decimal
- Multiply each digit by N raised to its position-from-right (0-indexed) and sum.
1011₂= 1·2³ + 0·2² + 1·2¹ + 1·2⁰ = 11. - From decimal to base N
- Repeatedly divide by N, reading remainders bottom to top.
255 → 16: 255÷16=15r15(F); 15÷16=0r15(F) → FF. - Binary ↔ Hex shortcut
- Each hex digit is exactly 4 binary bits. Group binary into nibbles from the right and translate one nibble at a time.
11111111=1111 1111= F F = FF. - Binary ↔ Octal shortcut
- Each octal digit is exactly 3 binary bits.
11111111=011 111 111= 3 7 7 = 377.
Signed mode (two's complement)
Computers store negative integers using two's complement: the top (most-significant) bit acts as a sign indicator, and a negative value is encoded by inverting all bits of its absolute value and adding 1. The biggest practical consequence: −1 is stored as “all 1s” — 0xFF in 8 bits, 0xFFFFFFFF in 32 bits, 0xFFFFFFFFFFFFFFFF in 64 bits.
Pick a bit width (8 / 16 / 32 / 64) and tick Signed. The decimal field now accepts negative values, and the binary / octal / hex fields show the two's-complement bit pattern. Type -1 in int32 and you get 0xFFFFFFFF; type 0x80 in int8 and you get -128 (the most negative value representable in 8 signed bits).
- int8 range
- −128 to 127
- int16 range
- −32,768 to 32,767
- int32 range
- −2,147,483,648 to 2,147,483,647
- int64 range
- −9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
The bit grid
Once a bit width is chosen, a grid appears below the number fields with one cell per bit, ordered most-significant-bit on the left. Each cell shows the bit's current value (0 or 1) and its position. Click any cell to flip that single bit — all four number fields update at the same instant. This is the fastest way to construct a value bit by bit when debugging a flag register, building a colour mask, or learning how each bit position contributes to the total.
The grid groups by byte (every 8 bits) with a small visual gap, matching how memory dumps are usually displayed.
Frequently asked questions
- Why does hex use A-F?
- Because we need 16 distinct digits but Arabic numerals only give us 10. The first six letters are the conventional choice for the values 10-15 — A=10, B=11, C=12, D=13, E=14, F=15. Both upper and lower case are accepted; the tool defaults to uppercase since most C-family languages do.
- What's the largest number this can handle?
- There's no fixed limit. JavaScript's BigInt grows to fit whatever you throw at it; a 1,000-bit binary string still converts cleanly. Performance starts to matter only above a few thousand digits.
- Can I paste expressions like '0xFF + 1'?
- No — only one value at a time. For arithmetic between bases, convert each operand here first, then use the basic calculator on the home page.
- Does it remember my preferences?
- Yes — uppercase hex, digit grouping, zero-pad to bit width, prefix display, signed mode, and bit width are all saved to your browser's localStorage and restored next time.