Converters

Number Base Converter

Convert numbers between binary, octal, decimal and hexadecimal.

Results are provided for general informational use. Verify important financial, health or legal figures before relying on them.

About this Number Base Converter

The Number Base Converter changes a number written in one base into its equivalent in another base. It supports the four bases most commonly used in computing and mathematics: binary, octal, decimal and hexadecimal.

Computers fundamentally operate in binary (base 2), but hexadecimal (base 16) is widely used in programming because it compactly represents binary values, making number base conversion a routine task for anyone working with computer science, color codes or memory addresses.

How the calculation works

The input is parsed as an integer in the source base, then rendered as a string in the target base using standard positional notation.

How to use it

  1. Enter a value and choose its current base.
  2. Choose the base you want to convert to.
  3. Select Convert to see the equivalent value.

Practical example

The decimal number 255 equals FF in hexadecimal, 377 in octal and 11111111 in binary.

The decimal number 255 converts to 11111111 in binary, 377 in octal, and FF in hexadecimal, and this specific number is a common sight in programming since it represents the maximum value a single 8-bit byte can hold.

Things to double-check

Each number base has a different set of valid digits: binary only uses 0 and 1, octal uses 0-7, decimal uses 0-9, and hexadecimal uses 0-9 plus A-F; entering a digit invalid for the chosen base will produce an error or incorrect result.

Counting in other bases

Decimal uses ten digits, binary uses two (0 and 1), octal uses eight and hexadecimal uses sixteen (0 to 9 and A to F). The binary number 1011 equals 8 plus 2 plus 1, which is 11. The decimal number 255 is 11111111 in binary and FF in hexadecimal, the largest value of one byte. To convert 45 to binary, divide repeatedly by 2 and read the remainders backwards, which gives 101101. The converter does this instantly and checks your digits.

Why hexadecimal is popular

Each hexadecimal digit stands for exactly four binary digits, so one byte is two hex digits. This makes hex a compact way to write binary data such as colours, memory addresses, error codes and MAC addresses. The colour #FF8000 is red 255, green 128 and blue 0. Programmers also use the 0x prefix, such as 0xFF, to mark hexadecimal in code.

Octal and file permissions

Octal is used in Unix file permissions. Each digit is made from three bits for read (4), write (2) and execute (1). The permission 755 means the owner has 7 (read, write, execute) and the group and others have 5 (read and execute), which appears as rwxr-xr-x. Understanding the binary behind the octal digit makes it easier to choose the right permission value.

Common pitfalls

Check that the digits are valid for the base: a 2 in a binary number or a G in hex is an error. Leading zeros do not change the value. Very large numbers can lose precision in browsers, so for values beyond about 9 quadrillion use dedicated big-number tools. Negative numbers in computers are stored using two's complement, which the plain base conversion does not apply, so a minus sign is simply carried through.

Binary sums and network addresses

Binary arithmetic works like decimal with only two digits. Adding 1011 (11) and 0110 (6) gives 10001, which is 17. In networking, an IPv4 address such as 192.168.1.1 is four bytes and can be written in hexadecimal as C0.A8.01.01. A subnet mask of 255.255.255.0 is 24 ones followed by 8 zeros in binary, written as slash 24. Converting between bases is a common skill in computer science courses and in configuring networks, and the converter lets you check each step.

Worked example: converting 156

To convert 156 to binary, find the largest powers of two that fit: 128, then 16, then 8, then 4, which add to 156, so the binary number is 10011100. To convert to hexadecimal, group the bits in fours: 1001 is 9 and 1100 is 12, written C, so the hex value is 9C. To convert to octal, group in threes from the right: 010, 011, 100 gives 234. As a check, 2 times 64 plus 3 times 8 plus 4 equals 156. The converter performs these steps instantly, but doing one by hand helps you see how the bases are related.

Hex in colours and memory

Because two hexadecimal digits describe one byte, hex is the natural way to write colours, memory addresses and network identifiers. The colour #FF8800 means red 255, green 136 and blue 0. A MAC address such as 00:1A:2B:3C:4D:5E is six bytes. Programmers often write a leading 0x, as in 0xFF, to show that a number is hexadecimal, and some languages use 0b for binary and 0o for octal. Being able to convert quickly helps you read error codes, debug data and check that two values are the same.

Binary operations and masks

Computers work with bits using operations such as AND, OR and XOR. An AND with 255 keeps the lowest eight bits of a number, which is how a mask extracts a single byte. A subnet mask of 255.255.255.0 keeps the first three bytes of an IP address. Shifting a binary number left by one place doubles it, and shifting right halves it, ignoring any remainder. Permissions in Unix systems use three bits for read, write and execute, so the digit 6 means 110 in binary, read and write without execute. Understanding binary makes these techniques much easier to follow.

Text and numbers in other forms

Characters are stored as numbers. The letter A is 65 in decimal, 41 in hexadecimal and 01000001 in binary. Unicode extends the idea to other scripts and symbols, and UTF-8 stores each character in one to four bytes. When a number is stored in memory, the order of bytes matters on different systems, which is called endianness. Be careful about the leading zeros in a binary number, which do not change its value but may matter for formats with a fixed width, and about numbers too large to be stored exactly in the browser.

Key terms explained

The base, or radix, of a number system is the count of distinct digits it uses. Decimal is base 10, binary is base 2, octal is base 8 and hexadecimal is base 16. A bit is one binary digit and a byte is eight bits. A nibble is four bits, which is exactly one hexadecimal digit. Place value means that each digit is multiplied by a power of the base according to its position. The most significant digit is the leftmost and the least significant is the rightmost.

Rules of thumb and quick checks

Memorise the powers of two: 1, 2, 4, 8, 16, 32, 64, 128 and 256. Hexadecimal digits A to F stand for 10 to 15. Four binary digits make one hex digit, so 1111 is F and 1010 is A. To convert binary to hex, group the bits in fours from the right. Check a conversion by converting back, and remember that FF is 255, 10 in hex is 16, and 100 in binary is 4.

Frequently asked questions

Does it support negative numbers?

Whole non-negative integers are supported.

Are hexadecimal letters case-sensitive?

No, both uppercase and lowercase letters are accepted for hexadecimal input.

Can I convert very large numbers?

Numbers are limited by standard JavaScript integer precision, which safely covers everyday use.

Why is hexadecimal commonly used in programming and web design?

Because each hexadecimal digit represents exactly 4 binary bits, hex provides a much more compact and human-readable way to represent binary data, which is why colors, memory addresses and byte values are frequently written in hex.

What digits are valid in octal?

Octal (base 8) only uses digits 0 through 7; there is no 8 or 9 in valid octal notation, since those values are represented instead by carrying over into an additional digit place.

Keep exploring

More Converters

View category →