Number Base Converter (binary, hex, decimal, octal)
Convert whole numbers between binary, octal, decimal, and hexadecimal, with the bit width and a place-value explanation.
Number bases
A number base is just how many digits you count with before carrying to the next column. Decimal uses ten (0–9), binary two (0–1), octal eight (0–7), and hexadecimal sixteen — 0–9 then A–F for the values ten to fifteen. The number itself doesn't change, only how it's written.
Place values
Each column is the base raised to a power. In decimal, 255 means 2×10² + 5×10¹ + 5×10⁰. The same value in binary is 11111111, which is 1×2⁷ + 1×2⁶ + … + 1×2⁰ = 255, and in hex it's FF, meaning 15×16¹ + 15×16⁰. Reading a number in any base is the same exercise with a different base.
Why hex and binary matter in computing
Computers store everything in bits, so binary is the native form — but long binary strings are painful to read. Hexadecimal is the shorthand:one hex digit is exactly four bits, so a byte (8 bits) is always two hex digits, from 00 to FF. That clean mapping is why memory addresses, colour codes, and byte dumps are written in hex. Octal groups bits in threes and survives mainly in Unix file permissions.
Worked example
Decimal 255 is binary 11111111, octal 377, and hex FF — the largest value a single byte can hold, which is why 255 shows up everywhere from colour channels to network masks. Split into nibbles, FF is 1111 1111: each F is four set bits.
Related
Colour codes use the same hex notation — see thehex to RGB converter — and file sizes count in binary multiples on thedata size converter.
Integers only, and case does not matter
Base conversion is exact and lossless for whole numbers, which is what this handles. Fractional values in a non-decimal base are a different problem: many terminating decimals do not terminate in binary — 0.1 is the classic example — which is the root of most floating-point surprises. Hexadecimal digits A–F are case-insensitive here, and very large values are limited by what a JavaScript number represents exactly, which is well beyond ordinary use.