Developer

Number Base Converter

Convert numbers between binary, octal, decimal, and hex

Input base

Base 2 โ€” Binary

11111111

0b11111111

Base 8 โ€” Octal

377

0o377

Base 10 โ€” Decimal

255

Base 16 โ€” Hexadecimal

FF

0xFF

Quick examples

Number Base Converter: Binary, Octal, Decimal & Hex

This converter lets you instantly convert any integer between the four number bases most commonly used in computing: binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16). It uses JavaScript's BigInt internally, so it handles arbitrarily large numbers with full precision โ€” no floating-point rounding errors.

The Four Bases

Binary (Base 2) uses digits 0 and 1. Computers represent every datum โ€” integers, floating-point numbers, text, images, instructions โ€” ultimately as sequences of bits. Understanding binary arithmetic underpins bitwise operations, bit masking, flags, and protocol field decoding.

Octal (Base 8) uses digits 0โ€“7. Its primary modern use is Unix file permissions (chmod values like 755 or 644), where each octal digit encodes three permission bits (read, write, execute).

Decimal (Base 10) is the everyday number system humans use. It is the bridge between the mathematical representation and the human-readable value.

Hexadecimal (Base 16) uses digits 0โ€“9 and Aโ€“F (or aโ€“f). Each hex digit represents exactly 4 bits, making it the most compact readable form of binary data. It appears in memory addresses, color codes, hashes, byte-level protocol fields, and assembly language.

Conversion Examples

  • 255โ‚โ‚€ = 11111111โ‚‚ = 377โ‚ˆ = FFโ‚โ‚† (one full byte, all bits set)
  • 1024โ‚โ‚€ = 10000000000โ‚‚ = 2000โ‚ˆ = 400โ‚โ‚† (2ยนโฐ)
  • 42โ‚โ‚€ = 101010โ‚‚ = 52โ‚ˆ = 2Aโ‚โ‚†
  • 16โ‚โ‚€ = 10000โ‚‚ = 20โ‚ˆ = 10โ‚โ‚†

How to Read Hex Colors

CSS/HTML hex colors like #1A2B3C encode red, green, and blue channels as two hex digits each: #RRGGBB. So #1A2B3C is R=1Aโ‚โ‚†=26, G=2Bโ‚โ‚†=43, B=3Cโ‚โ‚†=60. This converter makes decoding any color channel to its decimal value trivial.

Unix File Permissions (Octal)

When you run chmod 755 file, each octal digit maps to three permission bits for owner, group, and others:

  • 7 = 111โ‚‚ = read + write + execute
  • 6 = 110โ‚‚ = read + write
  • 5 = 101โ‚‚ = read + execute
  • 4 = 100โ‚‚ = read only
  • 0 = 000โ‚‚ = no permissions

Frequently Asked Questions

What is a number base (radix)?
A number base (or radix) is the number of unique digits a positional numeral system uses. Decimal (base 10) uses digits 0โ€“9. Binary (base 2) uses only 0 and 1. Octal (base 8) uses digits 0โ€“7. Hexadecimal (base 16) uses digits 0โ€“9 and letters Aโ€“F. Every integer can be expressed in any base โ€” this tool converts between the four most common ones used in computing.
Why do computers use binary?
Computers use binary because their underlying hardware โ€” transistors โ€” can only reliably represent two states: on (1) or off (0). Grouping bits into bytes (8 bits) and words allows encoding any integer. Binary is also why storage is in powers of 2: 1 KB = 1,024 bytes, 1 MB = 1,048,576 bytes, and so on.
When is hexadecimal used?
Hexadecimal is used throughout computing because it compactly represents binary data โ€” one hex digit = exactly 4 bits (a nibble), so one byte = two hex digits. It appears in memory addresses (0x7FFF0000), HTML/CSS color codes (#FF6347), SHA-256 hashes, MAC addresses, machine code listings, and IPv6 addresses.
When is octal used?
Octal historically appeared in older computing architectures. Today its most common use is Unix/Linux file permissions (e.g., chmod 755). The "755" means owner read/write/execute (7), group read/execute (5), and other read/execute (5), where each digit is a 3-bit binary group.
How do I convert binary to decimal by hand?
Write the binary number and, starting from the right, multiply each digit by its positional power of 2 and sum the results. Example: 1011โ‚‚ = 1ร—2ยณ + 0ร—2ยฒ + 1ร—2ยน + 1ร—2โฐ = 8 + 0 + 2 + 1 = 11โ‚โ‚€. This tool handles arbitrarily large numbers using BigInt arithmetic.
What is the 0x prefix for hex numbers?
The "0x" prefix is a convention from the C programming language used to indicate a hexadecimal literal, distinguishing it from a decimal number. For example, 0xFF means 255 in decimal. This tool automatically strips the 0x prefix if you paste a hex value with it.