The team behind OnlineTools4Free — building free, private browser tools.
Published Apr 1, 2026 · 7 min read · Reviewed by OnlineTools4Free
Number Base Conversion: Binary, Hex, Octal
Understanding Number Bases
We count in base 10 (decimal) because we have ten fingers. Computers operate in base 2 (binary) because transistors have two states: on and off. Programmers use base 16 (hexadecimal) because it maps cleanly to binary while being more compact, and base 8 (octal) for historical reasons tied to early computing architectures. These are all positional numeral systems — the value of each digit depends on its position.
In decimal, the number 347 means 3 hundreds + 4 tens + 7 ones, or 3×10² + 4×10¹ + 7×10⁰. The same positional logic applies to every base. In binary, the number 1011 means 1×2³ + 0×2² + 1×2¹ + 1×2⁰ = 8 + 0 + 2 + 1 = 11 in decimal. In hexadecimal, 2F means 2×16¹ + 15×16⁰ = 32 + 15 = 47 in decimal.
Hexadecimal uses digits 0-9 plus letters A-F to represent values 10-15. This gives each hex digit a range of 0 to 15, and since 16 = 2⁴, each hexadecimal digit maps to exactly four binary digits. The hex number A3 converts to binary as 10100011 — A becomes 1010, 3 becomes 0011. This direct mapping is why hex is the preferred compact notation for binary data.
How to Convert Between Bases
Any base to decimal: Multiply each digit by its base raised to the power of its position (counting from zero on the right), then sum the results. Binary 110101: 1×32 + 1×16 + 0×8 + 1×4 + 0×2 + 1×1 = 53. Hex FF: 15×16 + 15×1 = 255. Octal 77: 7×8 + 7×1 = 63.
Decimal to any base: Repeatedly divide the decimal number by the target base. The remainder of each division becomes a digit in the result (read from bottom to top). Convert 42 to binary: 42÷2=21 r0, 21÷2=10 r1, 10÷2=5 r0, 5÷2=2 r1, 2÷2=1 r0, 1÷2=0 r1. Reading remainders bottom-to-top: 101010.
Binary to hex (and back): Group binary digits into sets of four from the right, then convert each group to its hex equivalent. Binary 11010110 → 1101 0110 → D6. Going the other direction, replace each hex digit with its 4-bit binary equivalent. Hex 4F → 0100 1111.
Binary to octal (and back): Same idea but group in sets of three. Binary 11010110 → 011 010 110 → 326. Octal to binary: replace each octal digit with its 3-bit binary equivalent.
The grouping shortcuts between binary, hex, and octal exist because 16 and 8 are powers of 2. No such shortcut exists for decimal because 10 is not a power of 2, which is why binary-to-decimal conversion always requires arithmetic.
Practical Uses in Programming
Memory addresses and debugging: Memory addresses are displayed in hexadecimal because a 64-bit address like 0x7FFF5FBFF8A0 is far more readable than its binary equivalent (64 digits) or its decimal equivalent (a 16-digit number with no structural meaning). Hex addresses make it easy to see alignment, page boundaries, and relative offsets.
Colors: Web colors use hex notation. #FF5733 is red=255, green=87, blue=51. Each pair of hex digits represents one color channel from 0-255. Designers and developers read and write these values daily. #000000 is black, #FFFFFF is white, and you develop intuition for hex color values over time.
Bit manipulation: When working with flags, bitmasks, and low-level protocols, binary and hex make bit patterns visible. A permission mask of 0xFF0 clearly shows which bits are set. The same value in decimal (4080) obscures the bit structure. Bitwise operations (AND, OR, XOR, shift) are expressed more clearly in hex or binary.
File formats and encoding: Hex dumps show raw file contents. The first bytes of a file (magic numbers) identify its type: PNG files start with 89 50 4E 47, JPEG with FF D8 FF, PDF with 25 50 44 46. These patterns are easier to recognize and remember in hex than in decimal.
Unix permissions: The octal notation 755 means owner can read/write/execute (7=111 in binary), group can read/execute (5=101), others can read/execute (5=101). Each octal digit maps to three permission bits, making octal the natural base for this purpose.
Common Values to Know
Certain values appear so frequently that recognizing them across bases becomes second nature for programmers:
- 255 = FF hex = 11111111 binary — maximum value of an unsigned 8-bit byte
- 256 = 100 hex = 100000000 binary — number of values in a byte (0-255)
- 65535 = FFFF hex — maximum 16-bit unsigned value
- 127 = 7F hex — maximum signed 8-bit value
- 1024 = 400 hex = 10000000000 binary — 2¹⁰, the "kibi" prefix
- 0xDEADBEEF — a classic hex "magic number" used as a placeholder or debug marker
These values relate to the boundaries of data types, memory page sizes, and protocol field widths. Knowing them speeds up debugging and makes code review more efficient when reading low-level code.
Convert Number Bases Online
Our Number Base Converter converts numbers between binary, octal, decimal, hexadecimal, and any custom base up to 36. Enter a value in any base and see the equivalent in all other bases instantly. The tool shows the conversion steps so you can verify the math and learn the process.
All calculations run in your browser — no data is sent to a server. Use it for quick conversions during development, debugging, or learning about number systems.
Number Base Converter
Convert numbers between binary, octal, decimal, and hexadecimal bases.
OnlineTools4Free Team
The OnlineTools4Free Team
We are a small team of developers and designers building free, privacy-first browser tools. Every tool on this platform runs entirely in your browser — your files never leave your device.
