Number Base Converter - Binary, Octal, Decimal, Hex

Convert numbers between binary, octal, decimal, and hexadecimal instantly. Free number base converter online, no signup needed.

🔒 Your text stays in your browser - nothing is sent to our servers
Input base:
How to Use

Three steps to get started

1

Select input base

Choose Binary, Octal, Decimal, or Hexadecimal as the base of the number you will enter.

2

Enter a number

Type your number using digits valid for the selected base. Binary accepts 0 and 1; hex accepts 0–9 and A–F.

3

Copy any result

All four base representations appear instantly. Click Copy next to any result to use it in your code.

About This Tool

Number bases in computing

A number base (or radix) is the count of distinct digits a positional numeral system uses, and it determines the weight of each digit position: in base b, the digit at position n counting from the right contributes its value multiplied by bn. Every integer can be written in every base - the quantity is identical, only its notation changes. The decimal 255, binary 11111111, octal 377, and hex FF are four spellings of one number.

Computers are binary at the hardware level because a transistor has two stable states, so bases that are powers of two convert to and from binary with no arithmetic at all: hexadecimal groups bits four at a time, octal three at a time. Decimal, being a power of neither, always requires real division - which is why floating-point decimals like 0.1 cannot be represented exactly in binary and why currency should be stored in integer cents rather than floats.

Why hexadecimal dominates programming

Hex is popular because each hex digit maps perfectly to 4 bits, making it a compact way to write binary data. A 32-bit integer that takes 32 binary digits can be written with just 8 hex digits. This is why:

  • Memory addresses look like 0x7fff5fbff8b0
  • Colors in HTML/CSS are written as #1A5CFF
  • SHA-256 hashes are 64 hex characters (256 bits)
  • UUID/GUIDs use hex digits separated by hyphens
  • Byte values in debugging are shown as two hex digits each

Quick reference

Decimal 255 = Binary 11111111 = Octal 377 = Hex FF. Decimal 16 = Binary 10000 = Octal 20 = Hex 10. Decimal 1024 = Binary 10000000000 = Octal 2000 = Hex 400. Decimal 4095 = Binary 111111111111 = Octal 7777 = Hex FFF.

Literal syntax across languages

Most modern languages inherited C's prefixes but not all of them agree. C, C++, Java, JavaScript, Python 3, Rust, and Go all accept 0x for hex and 0b for binary. Octal is the divergence: C and Java use a bare leading zero, so 012 means 10, a classic source of bugs in code that pads numbers with zeros. Python 3, Rust, Go, and modern JavaScript require the unambiguous 0o prefix instead, and Python 3 rejects 012 outright. Rust and Java also allow underscores as digit separators - 0b1010_1010 - which JavaScript adopted in ES2021.

Two boundaries to keep in mind. JavaScript numbers are IEEE 754 doubles, so integers stay exact only up to Number.MAX_SAFE_INTEGER, 253 − 1 = 9,007,199,254,740,991; beyond that you need BigInt or a dedicated arbitrary-precision tool. And every base representation of a negative number depends on the signing convention - two's complement means the 8-bit pattern 11111111 is 255 unsigned but −1 signed.

Every conversion on this page is computed locally in your browser; no values are sent to a server or logged.

FAQ

Frequently Asked Questions

Related Tools