Binary Converter

Convert between binary, decimal, hexadecimal, and octal — plus text to binary

BIN Binary (Base 2)
DEC Decimal (Base 10)
HEX Hexadecimal (Base 16)
OCT Octal (Base 8)

Advertisement

Understanding Number Bases

Computers work exclusively with binary — 0s and 1s — because electronic circuits have two states: on and off. But representing large numbers in pure binary gets unwieldy fast. That's why developers use other bases as shortcuts:

BaseNameDigits usedWhy it's used
2Binary0, 1Native machine language
8Octal0–7Unix file permissions (e.g., chmod 755)
10Decimal0–9Human everyday counting
16Hexadecimal0–9, A–FCompact binary — 1 hex digit = 4 bits

How Binary Works

In binary (base 2), each digit position represents a power of 2. Reading right to left: 1, 2, 4, 8, 16, 32, 64, 128...

Example: 1011 in binary = 1×8 + 0×4 + 1×2 + 1×1 = 11 in decimal.

Computers group binary digits into bytes (8 bits). One byte can represent 256 values (0–255). That's why IP addresses have four numbers each capped at 255, and why ASCII characters fit within one byte.

Hexadecimal in Practice

Hexadecimal is everywhere in programming. CSS colors use it — #FF5733 is three hex pairs (FF=red, 57=green, 33=blue), each mapping to a decimal 0–255 value. Memory addresses, SHA hashes, MAC addresses, and HTML color codes all use hex because one hex character represents exactly 4 binary digits, making it a clean shorthand.

Octal and Unix Permissions

Octal shows up most often in Unix file permissions. chmod 755 means owner gets 7 (rwx = 4+2+1), group gets 5 (r-x = 4+0+1), and others get 5. Each octal digit represents exactly 3 binary digits, making permission bits readable at a glance.

Advertisement

Frequently Asked Questions

0x is a prefix indicating hexadecimal in most programming languages. So 0xFF means 255 in decimal. Similarly, 0b prefixes binary (0b1010 = 10) and 0o or 0 prefixes octal in many languages.
JavaScript's safe integer range is ±2⁵³ − 1 (about 9 quadrillion). For numbers beyond this range, use a language like Python that supports arbitrary-precision integers natively.
Each color channel (red, green, blue) ranges from 0 to 255 — exactly one byte. Two hex digits can represent any byte value (00 to FF), so a 6-character hex code compactly encodes three 0–255 values. It's shorter than rgb(255, 87, 51) once you're used to it.