Converter Tool

Number Base Converter

Convert numbers between binary, octal, decimal, and hexadecimal formats instantly.

Enter a number to see conversions...

Number Base Converter - Binary, Octal, Decimal, Hex

Number systems are the foundation of all computing. While humans typically use base-10 (decimal) for everyday counting, computers operate in base-2 (binary), and programmers frequently work with base-8 (octal) and base-16 (hexadecimal) for compact representation of binary data. Our Number Base Converter lets you instantly convert between all four bases with validation for each input format and copy buttons for quick results.

A number base (or radix) defines how many unique digits are used to represent numbers. In base-10, we use ten digits (0-9). In base-2, only two digits (0 and 1). In base-8, eight digits (0-7). In base-16, sixteen digits (0-9 and A-F, where A=10, B=11, and so on up to F=15). The same numerical value has different representations in different bases — the decimal number 255 is FF in hexadecimal, 377 in octal, and 11111111 in binary, but they all represent the same quantity.

Understanding number bases is essential for anyone working in computing, electronics, or digital systems. Whether you are setting file permissions in Linux (which uses octal), debugging memory addresses (hexadecimal), understanding color codes in web development (hex), or working with digital logic (binary), the ability to quickly convert between bases saves time and prevents errors. Our tool makes these conversions instant and accurate.

How Base Conversion Works

All base conversion goes through an intermediate step: the input number is first converted to its decimal (base-10) value, and then that decimal value is converted to the target base. Understanding this two-step process demystifies base conversion and helps you verify results manually when needed.

Conversion process:

To Decimal: Each digit is multiplied by the base raised to the power of its position (counting from right, starting at 0), and the results are summed. For example, the hexadecimal number FF = (15 × 16¹) + (15 × 16⁰) = 240 + 15 = 255.

From Decimal: The decimal number is repeatedly divided by the target base. The remainders, read in reverse order, form the number in the new base. For example, converting 255 to binary: 255 ÷ 2 = 127 R1, 127 ÷ 2 = 63 R1, 63 ÷ 2 = 31 R1, and so on, giving 11111111.

Direct conversion: For bases that are powers of 2 (binary, octal, hex), direct conversion is possible by grouping bits. Each octal digit corresponds to 3 binary bits, and each hex digit corresponds to 4 binary bits. This is why octal and hex are popular in computing — they provide a compact way to represent binary data without losing the direct correspondence to individual bits.

Quick reference — the number 255 in all bases:

Binary

11111111

Octal

377

Decimal

255

Hexadecimal

FF

Common Use Cases

Number base conversion is needed across many domains in computing and engineering. Here are the most common scenarios where quick and accurate base conversion saves time and prevents errors.

Web Development

  • Color codes: Convert hex colors (#FF5733) to RGB values (255, 87, 51)
  • Character codes: Convert Unicode code points between hex and decimal
  • CSS values: Convert between different color format representations
  • Network masks: Convert subnet masks between binary and decimal notation

Systems & Low-Level

  • File permissions: Convert Unix permissions (755, 644) to binary representation
  • Memory addresses: Convert hex addresses to decimal for calculations
  • Bit manipulation: Visualize bit patterns in different bases
  • Debug output: Convert hex dump values to readable decimal numbers

Programming and Number Bases

Programming languages have specific syntax for representing numbers in different bases. Understanding these conventions is essential for reading and writing code that uses non-decimal number representations. Here is how the most popular languages handle different bases.

Language syntax for number literals:

  • JavaScript/TypeScript: Binary uses the 0b prefix (0b1010 = 10), octal uses 0o (0o755 = 493), hex uses 0x (0xFF = 255). Without a prefix, numbers are decimal.
  • Python: Same prefixes as JavaScript: 0b for binary, 0o for octal, 0x for hex. Python also provides bin(), oct(), and hex() functions for conversion.
  • C/C++/Java: Binary uses 0b (C++14+ and Java 7+), octal uses a leading 0 (0755 = 493 — a common source of bugs), and hex uses 0x. Be careful with leading zeros, which indicate octal!
  • CSS: Colors are most commonly written in hexadecimal with a # prefix (#FF5733). Modern CSS also supports rgb() and hsl() functions for decimal representations.
  • Unix/Linux: File permissions use octal notation (chmod 755, chmod 644). Each digit represents read (4), write (2), and execute (1) permissions for owner, group, and others respectively.

Our Number Base Converter validates your input against the selected base, preventing common mistakes like entering "9" in octal mode or "G" in hexadecimal mode. The real-time conversion means you see results as you type, making it perfect for quick lookups during coding, debugging, or learning about number systems. All processing happens locally in your browser using JavaScript's built-in parseInt() and toString() functions.