Binary to Decimal Converter | Binary, Decimal, Octal & Hex

∛ Math & Numbers Free Forever

Binary to Decimal Converter All Number Bases

Convert between binary, decimal, octal, and hexadecimal in real time. Includes two’s complement signed mode, a positional value breakdown, and preset examples for common bit patterns.

Common Presets
Binary base 2
Decimal base 10
Octal base 8
Hexadecimal base 16
Type in any field above to see instant conversion to all other bases.
About This Tool

How this binary to decimal converter reads bits the way a processor does

Every number you type into a computer eventually becomes a string of electrical states, on or off, high or low. Binary is just the written form of that reality: base 2, using only the digits 0 and 1. This tool converts between binary, decimal, octal and hexadecimal live as you type, and it also shows you the positional math behind the conversion instead of hiding it behind a black box.

Everything happens in your browser with plain JavaScript arithmetic. No value you type is sent anywhere, logged, or stored. Refresh the page and it is gone.

The positional math, digit by digit

Decimal works in powers of ten: the digit 3 in 300 means 3 times 10 squared. Binary works the same way but with powers of two. Each bit position is worth double the one to its right, so reading a binary string is really just summing up the positions where a 1 appears.

Step 1 Assign exponents Number the bits from the rightmost, starting at exponent 0. The string 1011 has four bits, so from left to right the exponents are 3, 2, 1, 0.
Step 2 Weight each bit Multiply each bit by 2 raised to its exponent. A 0 contributes nothing regardless of position, a 1 contributes the full power of two.
Step 3 Sum the weighted values Add up every non-zero contribution. That total is the decimal value. For 1011 that is 8 + 0 + 2 + 1 = 11.
Step 4 Reuse the decimal for other bases Once the tool has the decimal value, it hands it to JavaScript’s native toString(8) and toString(16) to produce octal and hex, rather than converting binary directly to those bases.

This is exactly the breakdown the tool renders on screen under Positional Value Breakdown, one cell per bit showing the digit, its power of two, and its decimal contribution, so you can see the sum happening rather than just trust the answer.

// converting a decimal number back into a binary string function decToBinaryString(dec) { if (dec < 0) return ‘-‘ + Math.abs(dec).toString(2); return dec.toString(2); } // building the positional breakdown for the last 16 bits var exp = len – 1 – i; var val = bit === ‘1’ ? Math.pow(2, exp) : 0;

Negative numbers get special handling. Rather than silently expanding a negative value into a 32-bit two’s complement string, the converter keeps the sign separate and shows the magnitude with a minus sign in front, so the positional breakdown always lines up with what you actually typed.

BinaryPositional sumDecimal
10118 + 0 + 2 + 111
11111111128+64+32+16+8+4+2+1255
10000032 + 0 + 0 + 0 + 0 + 032
1010116 + 0 + 4 + 0 + 121
Worked example: two’s complement changes everything. Type 11111111 with the “8-bit two’s complement” option off and you get 255, the plain positional sum. Switch the option on and the same 8 bits become -1, because the leading 1 is now read as a sign bit rather than a place value. The tool flips every bit, adds 1, and negates the result, exactly how a processor’s arithmetic logic unit interprets signed binary. Getting this toggle wrong is the single most common source of “why is my binary math wrong” confusion in low level programming.

Why computers use base 2 at all

Transistors are reliable at distinguishing two states, current flowing or not, but far less reliable at distinguishing ten different voltage levels the way a base 10 system would require. Binary gives digital circuits a wide error margin between 0 and 1, which is why every modern processor, from a calculator chip to a data center server, ultimately operates in base 2 no matter what language or number system the programmer works in on top of it.

Live four-way sync

Typing in any of the four fields, binary, decimal, octal, hex, immediately recalculates the other three. There is no submit button because there is nothing to submit anywhere.

Grouped output

Binary results are grouped into clusters of four digits, the same nibble grouping used in datasheets and debuggers, which makes long bit strings far easier to read at a glance.

Where this comes up in real debugging

Bitmask flags in permission systems Network subnet masks Reading register values in embedded work Color channel math

File permission bits in Unix, IP subnet masks, and hardware register flags are all binary under the hood even though tools usually display them in octal or hex for brevity. Converting between the forms by hand is slow and error prone, which is the whole reason a fast bidirectional converter earns a permanent spot in a developer’s bookmarks.

Where base conversion matters

Setting Unix file permissions from an octal value, decoding a subnet mask into its binary form to check host ranges, reading raw register values off a microcontroller datasheet, verifying a bitmask used for feature flags in application code, and teaching students the place value system before they meet hexadecimal in a computer science course. Any task where you need to move between how a number looks and how a machine actually stores it lands here.

Common Questions

Frequently Asked Questions

Binary is a base-2 numeral system using only two digits: 0 and 1. Each digit position represents a power of 2, starting from 2^0 at the rightmost position and doubling leftward: 1, 2, 4, 8, 16, 32, 64, 128. To read a binary number, multiply each bit by its positional value and sum the results. For example, 1011 = 1×8 + 0x4 + 1×2 + 1×1 = 11 in decimal. Computers use binary because digital circuits naturally represent two states reliably and efficiently.

Write the binary number right to left. Assign each bit a positional value starting from 1 (powers of 2). Multiply each bit digit by its positional value, then sum all non zero products. Example: 110101 = 1×32 + 1×16 + 0x8 + 1×4 + 0x2 + 1×1 = 32 + 16 + 4 + 1 = 53. To convert decimal to binary, repeatedly divide by 2 and collect remainders from bottom to top: 53 divides to give bits 1,1,0,1,0,1, reading upward as 110101.

Octal (base 8) is used in Unix file permission notation (chmod 755). Each octal digit maps to exactly three binary bits. Hexadecimal (base 16) uses digits 0 to 9 plus A to F and is the standard notation for memory addresses, RGB colours, hash outputs, and machine code. Each hex digit maps to exactly four binary bits. Decimal does not have this clean binary mapping, which is why programmers prefer hex for compact binary representation.

Two’s complement is the standard method for signed integers in binary. For an n bit system, negative numbers are represented by inverting all bits of the positive value and adding 1. For 8 bit: -1 = 11111111, -128 = 10000000, 0 = 00000000, 127 = 01111111. The most significant bit is the sign bit. Two’s complement is preferred because addition and subtraction work identically for positive and negative numbers using the same hardware, and there is only one representation of zero.

Binary counting follows the same carry pattern as decimal but carries at 1 instead of 9. Sequence: 0, 1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010. Each time all bits are 1, adding one produces a new leading 1 with all others reset to 0. An n bit number can represent 2^n distinct values (0 to 2^n minus 1 unsigned, or minus 2^(n-1) to 2^(n-1) minus 1 signed).

A bit is a single binary digit (0 or 1). A byte is 8 bits, representing 256 values (0 to 255 unsigned). A word is a processor native unit: 32 bits on a 32 bit CPU, 64 bits on a 64 bit CPU. File sizes use bytes (kilobyte = 1,024 bytes), while network speeds use bits per second. An 8 Mbps connection transfers 1 MB per second because 8 megabits equals 1 megabyte.

Group binary digits into nibbles (groups of 4) from right to left, padding with leading zeros if needed. Convert each nibble to its hex digit: 0000=0 through 1111=F. Example: 10110111 splits into 1011 and 0111, which are B and 7, giving B7. This works because 16 = 2^4, so each hex digit represents exactly 4 binary bits. Octal similarly maps 3 bits per digit since 8 = 2^3.

A 10 bit address can reference 2^10 = 1,024 locations, close to but not exactly 1,000. This is why kilobyte traditionally meant 1,024 bytes. The IEC introduced gibibyte (GiB = 2^30) to disambiguate, but most consumer software still uses GB loosely. Hard drives market in decimal gigabytes (10^9 bytes) while operating systems measure in binary gibibytes (2^30 bytes), creating the common discrepancy where a 500 GB drive shows as roughly 465 GB.

Privacy Overview

Cookies let this site remember your preferences and show us which tools people actually use. Full detail sits in our Privacy Policy.