Number Base Converter

Last updated: May 2026

Convert between binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16) instantly.

🔢 Number Base Converter

Type in any field — all four bases update live

Binary (Base 2)
Digits: 0–1
Octal (Base 8)
Digits: 0–7
Decimal (Base 10)
Digits: 0–9, integers only
Hexadecimal (Base 16)
Digits: 0–9, A–F
Presets:

Enter a number above to see the conversion steps.

Why Number Bases Matter

Most of us grew up counting in base 10 — ten fingers, ten digits (0–9), powers of ten. Makes sense for humans. Computers, however, live in a world of switches that are either on or off, which maps to exactly two states: 0 and 1. That's why binary (base 2) is the native language of every CPU, every piece of memory, and every byte stored on disk.

Hexadecimal (base 16) became the programmer's shorthand for binary because four binary digits map perfectly to one hex digit. Instead of writing 11111111 you can write FF. That's why hex colors in CSS (#FF5733), memory addresses in debuggers (0x7FFFFFFF), and byte values in network packets are all expressed in hex — it's dense and readable without hiding the underlying binary structure.

Octal (base 8) had its heyday in Unix, where it still lives on through file permissions. Every Unix permission set is three groups of three bits — read, write, execute — and three bits is exactly one octal digit. When you run chmod 755 you're writing three octal digits that encode nine permission bits. Elegant.

Understanding how bases relate to each other isn't just academic. It helps you decode error messages, understand color pickers, reason about memory alignment, and write code that handles binary data without guessing.

Worked Example: Decimal 42

Starting number: 42 (decimal)

Decimal → Binary: Repeatedly divide by 2, reading remainders bottom-up.
42 ÷ 2 = 21 R 0  |  21 ÷ 2 = 10 R 1  |  10 ÷ 2 = 5 R 0  |  5 ÷ 2 = 2 R 1  |  2 ÷ 2 = 1 R 0  |  1 ÷ 2 = 0 R 1
Reading remainders from bottom: 101010

Decimal → Hexadecimal: Divide by 16.
42 ÷ 16 = 2 R 10 (10 = A in hex) → 2A

Decimal → Octal: Divide by 8.
42 ÷ 8 = 5 R 2  |  5 ÷ 8 = 0 R 5 → reading bottom-up: 52

Summary: 42 (decimal) = 101010 (binary) = 2A (hex) = 52 (octal)

Quick Reference: Decimal 0–16

Decimal Binary Hexadecimal Octal
0000
1111
21022
31133
410044
510155
611066
711177
81000810
91001911
101010A12
111011B13
121100C14
131101D15
141110E16
151111F17
16100001020

Frequently Asked Questions

What is binary and why do computers use it?

Binary (base 2) uses only two digits — 0 and 1 — which map perfectly to the two electrical states a transistor can hold: off (0) and on (1). Every file, image, and instruction on your computer is ultimately a sequence of these on/off signals. It's not that binary is especially elegant; it's just the simplest system that matches physical hardware reality. Trying to build a base-10 computer would require transistors with ten distinct voltage levels — noisy, imprecise, and expensive. Two states is robust and cheap.

How do I read hex color codes?

CSS hex colors like #FF5733 are three two-digit hex pairs packed together: FF = red (255), 57 = green (87), 33 = blue (51). Each pair ranges from 00 (decimal 0) to FF (decimal 255), giving 256 intensity levels per color channel. Multiply that out: 256 × 256 × 256 = 16,777,216 possible colors. Shorthand like #F57 expands to #FF5577 — each digit doubled. When you want a pure red, you want #FF0000. Pure white is #FFFFFF. Pure black is #000000. Once you internalize that FF = 255 and 00 = 0, hex color codes stop looking like alien text.

What do octal numbers have to do with Unix file permissions?

Unix permissions use three bits per entity (owner, group, other): read = 4 (100 in binary), write = 2 (010), execute = 1 (001). Each three-bit group maps cleanly to one octal digit. So chmod 755 means owner = 7 (rwx = 111), group = 5 (r-x = 101), other = 5 (r-x = 101). The reason octal was chosen is that three binary digits equals exactly one octal digit — so reading a permission bitmask as octal is lossless and compact. Try expressing the same thing in decimal and it immediately gets awkward.

What is base 64, and how is it different from the bases here?

Base64 is an encoding scheme rather than a pure positional number system. It uses 64 printable characters — A–Z, a–z, 0–9, +, and / — to represent binary data as plain ASCII text. The motivation is practical: many older protocols (email, HTTP headers, HTML attributes) were designed for text and can't safely carry raw binary bytes. Base64 solves this by encoding every 3 bytes of binary data as 4 base64 characters, adding roughly 33% overhead. You'll see it in data: URIs for inline images, JSON Web Tokens, and email attachments. It's not used for arithmetic — only for safe binary transport.

How do you convert negative numbers between bases?

In real computer systems, negative integers are typically stored using two's complement. To find the two's complement of a positive number: invert all bits (flip every 0 to 1 and vice versa), then add 1. For example, +1 in 8-bit binary is 00000001. Invert to get 11111110, add 1 to get 11111111 — which is −1 in 8-bit two's complement, and also 0xFF in hex. This approach makes binary addition work seamlessly for both positive and negative numbers without special-casing the sign. This tool works with non-negative integers; if you need two's complement representation, you also need to specify the bit width (8-bit, 16-bit, 32-bit, etc.).

Key Facts at a Glance

Why is 255 such a common number in computing?

255 is the largest value that fits in a single byte (8 bits). In binary it's 11111111 — all eight bits set to 1. In hex it's FF. It shows up constantly: maximum RGB color channel value, maximum alpha opacity, the subnet mask 255.255.255.0, and the upper limit of countless 8-bit fields in protocols and file formats.

What does "0x" mean before a number?

The "0x" prefix is a programming convention (from C, adopted by almost every language since) indicating that the number following it is in hexadecimal. So 0xFF = 255 in decimal. Similarly, 0b prefix means binary (0b11111111 = 255) and 0 as a leading zero sometimes means octal in older C code (0377 = 255). These prefixes exist so the compiler — and humans — know which base is being used.

How do I mentally convert small binary numbers to decimal?

Remember the place values: each bit position from right to left represents a power of 2 — 1, 2, 4, 8, 16, 32, 64, 128. To read 1011 in binary: 1×8 + 0×4 + 1×2 + 1×1 = 8 + 0 + 2 + 1 = 11. For hex, remember A=10, B=11, C=12, D=13, E=14, F=15, and multiply the left digit by 16.