Skip to content
Contania

Number Base Converter

Computers count in binary; programmers use hexadecimal; we use decimal. Convert a number between binary, octal, decimal and hexadecimal by entering its base.

Your numbers

Result

Binary
11111111
Hexadecimal
FF
Decimal
255
Octal
377
The same number in each base
BaseRepresentation
Binary (base 2)11111111
Octal (base 8)377
Decimal (base 10)255
Hexadecimal (base 16)FF

What a number base actually is

The base of a numeral system is simply how many digits it has before it must start a new column. Decimal (base 10) uses 0-9; binary (base 2) uses only 0 and 1; octal (base 8) uses 0-7; hexadecimal (base 16) runs 0-9 and then borrows letters, A=10 through F=15. What stays the same across all of them is positional notation: each column is worth the base raised to a power, counting from zero on the right. In decimal, 255 means 2×10² + 5×10¹ + 5×10⁰. In binary the same quantity is 11111111 — 128+64+32+16+8+4+2+1. In hexadecimal it is FF — 15×16 + 15. Three very different-looking strings, one number. Nothing about the quantity changes when you change base; only the notation does. Base 10 has no mathematical privilege at all — it is an accident of having ten fingers, and computers, which have none, settled on something else.

Reading binary

Binary place values double as you move left: 1, 2, 4, 8, 16, 32, 64, 128. To convert a binary number to decimal, add up the place values wherever there is a 1. So 1010 is 8 + 2 = 10, and 1101 is 8 + 4 + 1 = 13. Going the other way, divide repeatedly by 2 and read the remainders from the bottom up. Or work greedily from the largest power that fits: 200 = 128 + 64 + 8, which gives 11001000. The reason any of this exists is physical. A circuit reliably distinguishes two states — voltage present or absent — and distinguishing ten would be far more error-prone. So every digital device stores everything in binary, and every other base on this page is just a more readable way of writing the same bits. Eight bits form a byte, which is why 255 comes up so often: 11111111 is the largest value eight bits can hold, giving 256 distinct values from 0 to 255.

Why hexadecimal wins for programmers

Binary is correct and unreadable. A single 32-bit value is thirty-two characters of ones and zeros, and no human reliably spots a transposition in that. Hexadecimal fixes it with one clean property: 16 is 2⁴, so each hex digit maps to exactly four bits — a group called a nibble. The mapping is fixed and needs no arithmetic. F is 1111, A is 1010, 7 is 0111. Convert digit by digit and you are done: 0x2A is 0010 1010, which is 42. That makes two hex digits exactly one byte, and eight hex digits exactly one 32-bit word. A dump of memory in hex is four times shorter than the same dump in binary and converts back without a calculator. Decimal offers no such shortcut, because 10 is not a power of 2 — converting decimal to bits requires real division every time. The same trick is why octal exists: 8 is 2³, so each octal digit is exactly three bits. It was widely used on older machines whose word sizes were multiples of three bits, and hexadecimal displaced it once 8-, 16- and 32-bit architectures made groups of four the natural unit.

Where you meet hex without noticing

Web colors are the most common encounter. A CSS color like #FF0000 is three bytes written as three pairs of hex digits — red, green, blue, each from 00 to FF, that is 0 to 255. So #FF0000 is full red, #FFFFFF is white, #000000 is black, and #808080 is the midpoint gray. Three channels of 256 levels give 256³ = 16,777,216 colors, the "16 million" in a display spec. Memory addresses and pointers appear in hex because the digits align with the underlying bits, which matters when reading a crash dump. The 0x prefix is the standard marker for hexadecimal, mirrored by 0b for binary and 0o for octal in most modern languages. MAC addresses are six hex-encoded bytes; IPv6 addresses are written as eight groups of four hex digits precisely because a 128-bit address in decimal would be unreadable. Unicode code points use hex too — the U+ in U+1F600 introduces a hexadecimal number. And Unix file permissions are the classic octal survival. chmod 755 works because each permission group is exactly three bits — read, write, execute — and three bits is exactly one octal digit. 7 is 111 (rwx), 5 is 101 (r-x). The notation is not a coincidence; it is the base doing its job.

Converting between bases without a calculator

Three techniques cover almost everything. To decimal: multiply out the place values. Hex 1F4 is 1×256 + 15×16 + 4 = 500. From decimal: divide repeatedly by the target base and read the remainders bottom to top. For 500 into hex: 500 ÷ 16 = 31 remainder 4; 31 ÷ 16 = 1 remainder 15 (F); 1 ÷ 16 = 0 remainder 1. Bottom-up gives 1F4. Between binary, octal and hex: never go through decimal. Because all three bases are powers of two, you regroup bits directly — four at a time for hex, three at a time for octal, padding on the left. 11111111 splits as 1111 1111 = FF in hex, and as 11 111 111 = 377 in octal. A useful sanity check: the more digits a base has, the shorter the number. Any value will always be longest in binary, shorter in octal, shorter still in decimal, and shortest in hex. If a conversion produced a longer hex string than the binary original, something went wrong.

Frequently asked questions

Sources

Embed this calculator

Copy the code and paste it into your site or blog. Credit with a link back to Contania is included, and the height adjusts itself.

<iframe src="https://contania.app/embed/conversions/number-base-converter" title="Number Base Converter (Binary, Decimal, Hex)" width="100%" height="720" loading="lazy" style="border:1px solid #e5e0d8;border-radius:12px;max-width:640px"></iframe>
<script>window.addEventListener("message",function(e){if(e.data&&e.data.type==="contania:embed-height"){var f=document.querySelector('iframe[src="https://contania.app/embed/conversions/number-base-converter"]');if(f){f.style.height=e.data.height+"px"}}});</script>

Related calculators

Conversions

Data Storage

Convert digital storage between bits, bytes, KB, MB, GB and TB using binary units (1 KB = 1024 bytes), the way an operating system counts.

Calculate
Conversions

Unit Converter

Convert length between mm, cm, m, km, inches, feet, yards and miles — all at once. A complete metric-to-imperial length converter.

Calculate
Conversions

Roman Numerals

Convert Roman numerals to numbers and back. Type 2024 to get MMXXIV, or enter a Roman numeral to read its value. Works from 1 to 3999.

Calculate
Conversions

Pressure

Convert pressure between psi, bar, pascals (Pa), kilopascals (kPa), atmospheres (atm) and mmHg. Handy for tires, weather and engineering.

Calculate
Conversions

Shoe Size

Convert shoe sizes between US, EU and UK standards, with the foot length in cm and inches. Great for buying shoes from other countries.

Calculate
Conversions

Speed

Convert speed between mph, km/h, m/s, knots and ft/s. Enter a value and pick the units to convert from and to.

Calculate