Hex Calculator
Convert any number between hexadecimal, decimal, binary, and octal — all four representations side by side.
Hexadecimal
0xFF
- Decimal
- 255
- Binary
- 0b11111111
- Octal
- 0o377
How to use this calculator
Type your number in the input field and select the base it is written in — decimal (base 10), hex (base 16), binary (base 2), or octal (base 8). The calculator instantly shows that number in all four representations.
How the calculation works
Every number is just a count — the base only determines how many symbols are used before "rolling over". Decimal uses 0–9 (10 symbols), hex uses 0–9 and A–F (16 symbols), binary uses 0–1 (2 symbols), and octal uses 0–7 (8 symbols). Converting between them is a matter of re-expressing the same underlying integer in a different counting system.
Worked example
The decimal number 255 is 0xFF in hexadecimal (15×16 + 15), 0b11111111 in binary (eight 1-bits), and 0o377 in octal. All four are the same integer — just written differently. This is why 255 is the maximum value of a single byte: it takes exactly 8 binary digits (bits), or two hex digits (FF).
Frequently asked questions
What is hexadecimal?
Hexadecimal (base 16) is a counting system that uses 16 symbols: the digits 0–9 plus the letters A–F (where A=10, B=11, C=12, D=13, E=14, F=15). It is widely used in computing because one hex digit maps exactly to four binary digits (a nibble), making it a compact, human-readable way to represent binary data. Memory addresses, colour codes (#RRGGBB), and byte values are all commonly expressed in hex.
What does the 0x prefix mean?
0x is a convention used in most programming languages (C, JavaScript, Python, etc.) to indicate that a number literal is written in hexadecimal. For example, 0xFF means "the hex number FF", which equals decimal 255. Similarly, 0b means binary (0b11111111) and 0o means octal (0o377). This calculator accepts and displays numbers with these prefixes.
Why do programmers use hex?
Binary (base 2) maps perfectly to how computers store data in bits, but long binary strings like 11111111 are hard to read. Hex is a shorthand: every four binary digits collapse into a single hex digit. So 11111111 → FF. Two hex digits represent one byte (8 bits), making hex a natural fit for memory addresses, colour values, file formats, and low-level data inspection.
What is binary (base 2)?
Binary is the number system computers use internally. Every value is stored as a sequence of bits (binary digits), each either 0 or 1. A single bit holds one piece of true/false information. Eight bits form a byte, which can hold values 0–255. Binary arithmetic is simple for circuits to implement with transistors, which naturally represent on/off states.
What is octal (base 8)?
Octal uses the digits 0–7. It was historically used in computing because early systems grouped bits in threes rather than fours. Today it survives mainly in Unix/Linux file permissions — a permission like chmod 755 is an octal number: 7 = rwx (read+write+execute), 5 = r-x (read+execute), 5 = r-x.
How do I convert hex to decimal by hand?
Multiply each hex digit by 16 raised to its position power, starting from 0 on the right. Example: 2F hex = (2 × 16¹) + (F × 16⁰) = 32 + 15 = 47 decimal. For digits A–F, substitute their decimal values (A=10 through F=15) before multiplying.