{ }
中文

Number Base Converter

Type a value in any base — binary, octal, decimal, or hex — and see it instantly in the other three.

Binary (base 2)11111111
Octal (base 8)377
Decimal (base 10)255
Hexadecimal (base 16)ff

Why number bases matter

Computers store numbers as bits, but humans rarely read bits directly. Hexadecimal compresses four bits into a single character, making memory dumps, MAC addresses, color values, and file headers much easier to skim. Octal encodes three bits per character and survives in Unix file permissions. Binary is the canonical machine representation and shows up whenever bit manipulation matters.

This converter lets you type a number in any base and see it instantly in all four common bases. The classic JavaScript prefixes are recognised: 0b for binary, 0o for octal, 0x for hex, and a bare decimal otherwise. You can also force a base using the dropdown — useful when an ambiguous input such as 100 could be interpreted as 4 (binary), 64 (octal), 100 (decimal), or 256 (hex).

Use cases

  • Inspect a colour HEX value as RGB component bits.
  • Translate Unix file permissions between octal (0755) and the binary rwxrwxrwx layout.
  • Read a memory address copied from a debugger and convert it to decimal.
  • Encode a port number or magic constant as hex for a binary file format.
  • Convert a Base64 alphabet index back to a 6-bit binary chunk.

Best practices

  • Use the 0x prefix for hex literals in code so a reader is never in doubt about the base.
  • Group long binary numbers in nibbles (4 bits) to make them easier to read.
  • Be aware that JavaScript bitwise operators coerce to 32-bit signed integers — large hex values may surprise you.
  • When converting negative numbers across bases, decide up front whether you want sign-magnitude or two's complement.

Frequently asked questions

What is the largest number this tool supports?
JavaScript's safe integer range, 2^53 - 1. Numbers outside this range may lose precision.
How does it handle negative numbers?
Decimal accepts a leading minus sign. Other bases display the absolute value with a minus sign rather than the two's-complement representation, which depends on bit width.
Are leading zeros preserved?
We strip leading zeros except when needed to indicate the base prefix or to align nibbles in binary output.
Is hex case-sensitive?
Input accepts both 0xFF and 0xff. Output is lowercase by default to match modern conventions.