Number Base Converter

Convert between Binary, Decimal, Hexadecimal, and Octal instantly.

Safe conversion with no data sent to server

Last updated: March 2026

Binary (Base 2)

0b11111111

Decimal (Base 10)

255

Hexadecimal (Base 16)

0xFF

Octal (Base 8)

0o377

What is Number Base Conversion?

A number base (or radix) defines how many unique digits are used to represent numbers in a positional numeral system. The four most common bases in computing are: decimal (base 10, digits 0-9), binary (base 2, digits 0-1), octal (base 8, digits 0-7), and hexadecimal (base 16, digits 0-9 and A-F). Each position in a number represents a power of the base. For example, the decimal number 255 means 2x10^2 + 5x10^1 + 5x10^0 = 255, while the binary number 11111111 means 1x2^7 + 1x2^6 + ... + 1x2^0 = 255.

Binary is the fundamental language of digital computers because transistors operate in two states (on/off, 1/0). Every piece of data -- text, images, videos, programs -- is ultimately stored and processed as sequences of binary digits (bits). However, reading long binary strings is error-prone for humans, so octal and hexadecimal serve as compact shorthand. Each octal digit represents exactly 3 binary digits (bits), and each hexadecimal digit represents exactly 4 bits. This is why 255 in decimal = 11111111 in binary = 377 in octal = FF in hexadecimal.

The conversion algorithm works in two steps. First, the input is parsed from its source base into an intermediate decimal value by summing digit x base^position for each digit. Second, the decimal value is repeatedly divided by the target base, collecting remainders in reverse order to form the result. For example, converting decimal 255 to hexadecimal: 255 / 16 = 15 remainder 15 (F), 15 / 16 = 0 remainder 15 (F), reading remainders bottom-up gives FF. The prefixes 0b (binary), 0o (octal), and 0x (hexadecimal) are standard conventions for indicating the base of a written number.

How to Use This Number Base Converter

Step-by-step instructions:

  1. Select the input base by clicking one of the four buttons: Binary, Decimal, Hexadecimal, or Octal.
  2. Type your number in the input field. The placeholder shows an example value for the selected base.
  3. If you enter an invalid character for the selected base (e.g., "2" in binary or "G" in hexadecimal), a validation error appears immediately.
  4. All four base representations are displayed simultaneously in the results grid below, with the source base highlighted in blue.
  5. Click the copy button next to any result to copy that specific representation to your clipboard.
  6. Switching the input base clears the input field so you can enter a new value in the selected base.

Hexadecimal input is case-insensitive: both "ff" and "FF" are accepted. Results are displayed in uppercase for consistency.

Practical Applications

  • Programming and debugging: Developers frequently need to convert between hex and binary when working with memory addresses, bitwise operations, file headers, and low-level protocols.
  • Web development (CSS colors): CSS hex color codes like #FF5733 are hexadecimal representations of RGB values. Converting FF to decimal gives 255 (full red), 57 gives 87 (green), 33 gives 51 (blue).
  • Networking (IP addresses and subnets): Subnet masks and IP addresses are often analyzed in binary to understand network/host bit boundaries. For example, /24 means 11111111.11111111.11111111.00000000 in binary.
  • File format analysis: Hex editors display file contents in hexadecimal. Understanding hex-to-binary conversion is essential for analyzing file headers, magic bytes, and binary protocols.
  • Digital electronics: Hardware engineers work with binary and hexadecimal when designing logic circuits, programming FPGAs, and reading datasheets that specify register values in hex.
  • Assembly language programming: Machine code instructions and memory addresses are conventionally written in hexadecimal for readability while maintaining a direct mapping to binary.
  • Permissions (Unix/Linux): Unix file permissions use octal notation: chmod 755 means rwxr-xr-x in binary (111 101 101), where each octal digit maps to 3 permission bits.

FAQ

Why is hexadecimal so widely used in computing instead of decimal?

Hexadecimal provides a compact, human-readable representation of binary data. Each hex digit maps to exactly 4 binary bits, so a byte (8 bits) is always exactly 2 hex digits. This makes it easy to mentally convert between hex and binary, inspect memory contents, and work with addresses. Decimal has no such clean mapping to binary bit groups.

What is the largest number this converter can handle?

This converter uses JavaScript's built-in parseInt and toString methods, which handle standard integer precision up to 2^53 - 1 (9,007,199,254,740,991 in decimal). For most practical purposes -- including 32-bit and 64-bit addresses -- this is more than sufficient.

Why do binary numbers get so long compared to other bases?

Because binary uses only 2 symbols, it requires the most digits to represent a given value. The number of digits needed is approximately log2(N) for binary vs. log10(N) for decimal. For instance, the decimal number 255 is just 3 digits in decimal but 8 digits in binary (11111111). This is precisely why hex (base 16) is preferred for display -- it compresses 4 binary digits into 1.

What do the prefixes 0b, 0o, and 0x mean?

These are standard programming conventions to indicate number bases in source code. 0b or 0B denotes binary (e.g., 0b1010 = 10), 0o or 0O denotes octal (e.g., 0o12 = 10), and 0x or 0X denotes hexadecimal (e.g., 0xA = 10). Most programming languages including JavaScript, Python, C, and Java support these prefixes.