Copied!
Back
Math Tool

Number Base Converter

Convert between binary, decimal, hexadecimal, and octal number systems instantly. This free online number base converter supports radix conversion for any base from 2 to 36, with BigInt precision for arbitrarily large numbers. Explore positional notation across base-2, base-8, base-10, and base-16 numeral systems with grouped nibbles, bit-length display, and real-time input validation. All conversions happen client-side in your browser.

Last updated: May 2026 · Reviewed by FreeDevTool systems engineering team
number-base.tool
Binary Base 2
Octal Base 8
Decimal Base 10
Hexadecimal Base 16
 bits
Fits in

Number bases explained — binary, octal, hex, decimal, and the math behind radix conversion

If you have ever stared at 0xDEADBEEF in a stack trace or typed chmod 755 without thinking about it, you are already using positional number systems. This guide unpacks why programmers care about base-2, base-8, and base-16 — what each one buys you, how the conversion math actually works, what "two's complement" means in practice, and the language-specific syntax you need so the same number reads the same in JavaScript, Python, Go, Rust, and C.

Positional notation — the one rule behind every base

A number written in any base is a sum of digits multiplied by powers of that base. The decimal number 214 is 2×10² + 1×10¹ + 4×10⁰. Take the same idea and swap 10 for any other base:

Notice that 214 has eight binary digits, three octal digits, three decimal digits, and two hex digits. Higher bases are denser — that is why programmers prefer hex over binary for byte-level work.

Why each base matters

BaseDigitsWhere you see it
Binary (2)0, 1Bit flags, hardware registers, network masks, low-level protocols.
Octal (8)0–7Unix file permissions (chmod 755), legacy PDP-11 systems, some C string escapes (\137).
Decimal (10)0–9Human-readable numbers, financial values, anything user-facing.
Hexadecimal (16)0–9, A–FMemory addresses, RGB color (#FF5733), MAC addresses, JWT signatures, hashes, byte dumps.
Base-32 / Base-360–9, A–V or A–ZCrockford base32 in ULIDs, base36 in short-link IDs.
Base-58Bitcoin alphabet (no 0, O, I, l)Bitcoin addresses, Solana keys.
Base-64A–Z, a–z, 0–9, +, /Embedding binary in text (data URIs, basic auth, JWT body).

Octal feels archaic, but every Unix admin uses it daily — chmod 644 file sets permissions to 110 100 100 in binary (rw- r-- r--).

Two's complement — how computers represent negatives

Computers store integers as fixed-width bit patterns. The trick to representing negative numbers is two's complement: the most-significant bit's place-value is negated. In an 8-bit signed integer, the leftmost bit's value is −128 instead of +128:

Binary (8 bits)UnsignedSigned (two's complement)
0000000000
0000000111
01111111127127
10000000128−128
11111111255−1

To negate a two's-complement number: invert every bit, then add 1. So +5 = 00000101, invert → 11111010, +1 → 11111011 = −5. The reason this encoding won is that addition and subtraction work the same circuit regardless of sign — no special case for negatives.

Bitwise operators — what each one is for

OperatorEffectUse it for
& AND1 only when both bits are 1Mask: keep specific bits, drop the rest. x & 0xFF = low 8 bits.
| OR1 when either bit is 1Set bits: flags | READ turns on READ.
^ XOR1 when bits differToggle bits, simple cipher round, parity check.
~ NOTFlip every bitBitmask building: ~0xFF clears low byte.
<< shift leftMultiply by 2 per shiftBuild a single-bit mask: 1 << 7 = bit 7.
>> shift right (arithmetic)Divide by 2; preserves sign bitSign-aware integer division by powers of 2.
>>> shift right (logical, JS)Divide by 2; fills with 0Treating the value as unsigned.

Bit width and overflow — the trap that bites every junior dev

The same number can fit in 8, 16, 32, or 64 bits, with different limits at each width. The four widths you will see most:

TypeBitsUnsigned rangeSigned range
byte / uint880 to 255−128 to 127
short / int16160 to 65 535−32 768 to 32 767
int / int32320 to 4 294 967 295−2 147 483 648 to 2 147 483 647
long / int64640 to 18.4 × 10¹⁸−9.22 × 10¹⁸ to 9.22 × 10¹⁸

The classic int32 overflow: Math.pow(2, 31) - 1 in 32-bit signed wraps to −2 147 483 648 if you add 1. JavaScript number conversions to int32 (x | 0) hit this, and so does every SELECT count(*) on a table with billions of rows in a 32-bit-id schema. Use 64-bit types for anything that can grow.

Number-base literals across 8 languages

LanguageBinaryOctalHexUnderscores
JavaScript / TypeScript0b11010o7550xDEADYes (1_000_000)
Python 30b11010o7550xDEADYes
Go0b11010o7550xDEADYes (Go 1.13+)
Rust0b11010o7550xDEADYes
Java 7+0b11010755 (no o)0xDEADYes
C / C++14+0b110107550xDEADYes (C++14: 1'000'000)
Ruby0b11010755 or 0o7550xDEADYes
SQL (Postgres)B'1101'x'DEAD'

The bare-leading-zero octal in C, C++, Java, Ruby (0755) is a historical hazard. parseInt("08") in old JavaScript returned 0 because of it; ES5 fixed that, but the lesson is to write 0o explicitly.

Common base-conversion mistakes

Best number base converter for 2026 — what to compare

Search results for "binary to decimal", "hex converter", "number base converter" return many tools but most fail on real-world numbers: they cap at 32-bit (silently truncating large values), they don't handle two's complement for negative numbers, they only support binary/octal/decimal/hex (skipping base32, base36, base58 for crypto), or they don't display the bit-length / grouped-nibble formatting needed for low-level debugging. Here's how the most-used base converters compare in 2026:

ToolBigInt (no precision loss)Bases supportedTwo's complementBit length displayCost
FreeDevTool Number BaseYes2 through 36YesYes (with grouping)Free
rapidtables.com/convert/number32-bit limitBin/Oct/Dec/HexNoNoFree, ad-funded
binaryhexconverter.comLimitedBin/Oct/Dec/HexNoNoFree, ad-heavy
Windows Calculator (Programmer mode)64-bitBin/Oct/Dec/HexYesYesBuilt-in
JavaScript parseInt(str, base)53-bit float2-36ManualManualBuilt-in
Python int(str, base)Arbitrary precision2-36ManualManualBuilt-in

How do I convert binary to decimal (or hex to decimal) online?

Type your binary number in the binary input field — decimal, octal, and hex update instantly. The converter uses JavaScript BigInt internally so a 200-bit binary number converts without precision loss (unlike parseInt which silently rounds past 53 bits). For binary like 11010110: type or paste the digits, see decimal 214, hex 0xD6, octal 0o326 instantly. For hex with prefix: type 0xDEADBEEF or just DEADBEEF — both parse. The bit-length indicator shows the minimum bits required (8 bits for 0xD6, 32 bits for 0xDEADBEEF) which matters for fixed-width register debugging.

What's the difference between binary, octal, decimal, hex, and base64?

BaseDigits usedCommon use
Binary (2)0, 1Bitwise ops, low-level memory representation
Octal (8)0-7Unix file permissions (chmod 755)
Decimal (10)0-9Default human notation
Hexadecimal (16)0-9, a-fColor codes (#FF0000), memory addresses, byte representation
Base32 (Crockford)0-9, a-z minus i, l, o, uULID, AWS S3 ARN, human-typeable IDs
Base360-9, a-zCompact alphanumeric IDs, short URL slugs
Base58 (Bitcoin)1-9, A-Z, a-z minus 0/O/I/lBitcoin/Monero addresses, short IDs
Base64A-Z, a-z, 0-9, +, /Binary-to-text encoding (use Base64 Encoder)

Decision rule: bitwise debugging → binary. Linux file perms → octal. Color/memory/byte → hex. Database short IDs → base36. Crypto / Bitcoin → base58. Binary blob in JSON → base64 (different operation, see Base64 Encoder).

Number base converter alternative to rapidtables.com — 4 reasons developers switched

  1. BigInt support — no 32-bit truncation. rapidtables silently truncates numbers above 2^32. This converter handles arbitrary-precision integers (200+ bits) for debugging large hashes or hex memory dumps.
  2. Two's complement for negative numbers. Type -1 and see the two's-complement bit pattern at any bit-width (8/16/32/64) — useful for embedded systems and bit-flag debugging.
  3. Bases 2 through 36, not just 4. base32 (Crockford), base36 (short IDs), and any custom radix work in addition to binary/octal/decimal/hex.
  4. No ads, no popups. rapidtables and binaryhexconverter both inject ads. This page is browser-only and ad-free.

Pair the number base converter with the Hex to RGB Converter for color work, the Chmod Calculator for octal Unix permissions, the Byte Converter for KB/MB/GB conversion, and the Encoding Tools hub for the broader transform toolkit.

Frequently Asked Questions

How do I convert binary to decimal?
To convert binary to decimal, multiply each bit by 2 raised to the power of its position (starting from 0 on the right) and sum the results. For example, binary 1011 = (1 × 2³) + (0 × 2²) + (1 × 2¹) + (1 × 2&sup0;) = 8 + 0 + 2 + 1 = 11 in decimal. This positional notation principle applies to all numeral systems — the digit value is multiplied by the base raised to its position index.
What is hexadecimal and why is it used in programming?
Hexadecimal (base-16) uses digits 0–9 and letters A–F. Each hex digit maps to exactly 4 binary bits (a nibble), making it a compact way to represent binary data. For example, 0xFF = 11111111 in binary = 255 in decimal. Programmers use hex for memory addresses, color codes, byte values, and bitwise operations because it is far more readable than long binary strings while maintaining a direct relationship with the underlying binary system.
How do I convert between octal and binary?
Each octal digit corresponds to exactly 3 binary bits. To convert octal to binary, replace each digit with its 3-bit binary equivalent: 0=000, 1=001, 2=010, 3=011, 4=100, 5=101, 6=110, 7=111. For example, octal 357 = 011 101 111 in binary. To go from binary to octal, group binary digits into sets of 3 from the right and convert each group to its octal equivalent.
What bases are commonly used in computer science?
The most common bases are: Binary (base-2) — the fundamental language of computers, using 0s and 1s. Octal (base-8) — used in Unix file permissions and some legacy systems. Decimal (base-10) — the standard human numeral system. Hexadecimal (base-16) — widely used for memory addresses, color codes, and representing byte values compactly. Some systems also use base-36 (digits + entire alphabet) for compact ID encoding.
What is the difference between signed and unsigned binary numbers?
Unsigned binary numbers represent only non-negative values — an 8-bit unsigned number ranges from 0 to 255. Signed binary uses the most significant bit (MSB) as a sign indicator. In two's complement (the most common signed representation), an 8-bit signed number ranges from −128 to 127. The binary value 11111111 is 255 when unsigned, but −1 in signed two's complement. Understanding this distinction is crucial for low-level programming and bitwise operations in languages like C and Rust.

Browse all 50 free developer tools

All tools run in your browser, no signup required, nothing sent to a server.