Number Base Converter

Convert numbers between binary, octal, decimal, hexadecimal, and any base from 2 to 36. See step-by-step conversion breakdowns.

This number base converter handles instant, bidirectional conversion between binary (base 2), octal (base 8), decimal (base 10), hexadecimal (base 16), and any custom base from 2 to 36. Type a value in any field and all others update in real time. It uses BigInt internally for arbitrary precision, so it handles numbers of any size without losing accuracy. Everything runs in your browser with no server calls.

Ad
Ad

About Number Base Converter

Common Number Bases

BaseNameDigitsCommon Uses
2Binary0, 1Digital logic, bitwise operations, flags, permissions
8Octal0-7Unix file permissions (chmod 755), some legacy systems
10Decimal0-9Human counting, everyday math, most user-facing displays
16Hexadecimal0-9, A-FMemory addresses, colour codes, byte values, MAC addresses

These four bases cover the vast majority of practical use cases. Binary is the native language of digital hardware, decimal is what humans count with, octal maps cleanly to 3-bit groups used in Unix permissions, and hexadecimal maps to 4-bit nibbles - making it the standard shorthand for raw binary data.

How Base Conversion Works

Every number base uses positional notation, where each digit represents a power of the base. The concept dates back to the ancient Sumerians in the 3rd millennium BC, who developed the first known positional numeral system using base 60 (sexagesimal). The key insight is that the value of a digit depends on both the digit itself and its position in the number.

To convert from any base to decimal, multiply each digit by its positional power and sum the results. Here is a worked example converting hex 1A3 to decimal:

Hex DigitPosition (right to left)Power of 16Decimal Value
1216^2 = 2561 x 256 = 256
A (10)116^1 = 1610 x 16 = 160
3016^0 = 13 x 1 = 3

So hex 1A3 = 256 + 160 + 3 = 419 in decimal.

To convert from decimal to another base, repeatedly divide by the target base and collect the remainders in reverse order. For example, converting decimal 419 to octal: 419 / 8 = 52 remainder 3, 52 / 8 = 6 remainder 4, 6 / 8 = 0 remainder 6. Reading the remainders bottom-up gives octal 643. The Hex to Decimal Converter provides a focused interface for that specific conversion with step-by-step breakdowns.

How Does the Hex-Binary Relationship Work?

Each hexadecimal digit maps to exactly 4 binary digits (bits), and this clean one-to-four mapping is why hex is the preferred shorthand for binary data. A single byte (8 bits) is always represented by exactly two hex characters, making it trivial to read byte values. A 64-bit memory address that would stretch to 64 binary digits is just 16 hex characters - for example, 0x00007FFE12345678.

HexBinaryHexBinary
0000081000
1000191001
20010A1010
30011B1011
40100C1100
50101D1101
60110E1110
70111F1111

To convert binary to hex, group the bits into sets of 4 from right to left and replace each group with its hex digit. For example, binary 1010 1111 becomes hex AF. Going the other direction, hex C7 expands to binary 1100 0111. This grouping trick also works for octal - each octal digit maps to exactly 3 bits, so octal 755 expands to binary 111 101 101.

Where Each Base Appears in Programming

ContextBaseExampleWhy This Base
CSS colour codesHex (16)#FF5733Two hex digits per colour channel (0-255 = 00-FF)
Memory addressesHex (16)0x7FFE1234Compact representation of binary addresses
Unix permissionsOctal (8)chmod 755Each octal digit maps to 3 permission bits (rwx)
IPv4 subnet masksBinary (2)11111111.11111111.11111111.00000000Subnet masks and CIDR use bitwise operations
IPv6 addressesHex (16)2001:0db8::ff00:0042:8329128 bits displayed as 8 groups of 4 hex digits (RFC 4291)
MAC addressesHex (16)A1:B2:C3:D4:E5:F66 bytes displayed as 12 hex digits
UUID valuesHex (16)550e8400-e29b-41d4-a716-446655440000128 bits displayed as 32 hex digits
Unicode code pointsHex (16)U+0041 (letter A)Compact representation of up to 21-bit values
Bitwise flagsBinary (2)0b1010 (features A and C on)Each bit represents an on/off flag

The Chmod Calculator shows how octal maps to Unix file permissions in practice - each digit represents the read, write, and execute bits for owner, group, and others.

Base Prefixes in Programming Languages

Most modern languages use prefix notation to specify number literals in different bases. Without a prefix, numbers default to decimal. The table below shows prefix syntax across the most widely used languages:

BaseJavaScriptPythonC / C++ / GoJavaRust
Binary (2)0b10100b10100b10100b1010 (Java 7+)0b1010
Octal (8)0o7550o755075507550o755
Hex (16)0xFF0xFF0xFF0xFF0xFF

One historical gotcha: in C and Java, a leading zero means octal, not decimal. Writing 010 in C gives 8 (octal), not 10 (decimal). JavaScript originally followed this convention but modern strict mode rejects it - use 0o10 instead. Python 3 also requires the 0o prefix for octal and raises a SyntaxError on bare leading zeros.

A Brief History of Number Bases

The Sumerians developed base 60 around 3000 BC, and the Babylonians refined it into the first true positional system. Base 60 survives today in timekeeping (60 seconds per minute, 60 minutes per hour) and angle measurement (360 degrees = 6 x 60). The number 60 has twelve factors (1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60), which made division simpler in an era before calculators.

Binary was formalised by Gottfried Wilhelm Leibniz, who published "Explication de l'Arithmetique Binaire" in 1703. He described how all integers could be represented with just 0 and 1, though he viewed it more as a philosophical tool than a practical computing system. It took until the 1930s and 1940s, with Claude Shannon's work on Boolean algebra and the first electronic computers, for binary to become the foundation of digital computing.

Hexadecimal gained widespread adoption in the 1960s with IBM's System/360 mainframe, which used 8-bit bytes grouped into 32-bit words. Displaying a 32-bit value as eight hex digits was far more practical than 32 binary digits. That convention has stuck - every modern debugger, hex editor, and memory inspector defaults to hexadecimal display.

Less Common Bases

BaseNameUsed In
3TernaryBalanced ternary computing (Soviet Setun computer, 1958), some puzzle solutions
12DuodecimalTimekeeping (12 hours), imperial measurements (12 inches per foot)
20VigesimalMayan numeral system, French counting (quatre-vingts = 4 x 20 for 80)
32Base 32Crockford's Base32 encoding, geohash coordinates
36Base 36URL shorteners, compact identifiers (uses full 0-9 + A-Z)
60SexagesimalTime (60 seconds/minutes), angles (60 arc-minutes per degree)
64Base 64Email attachments (MIME), data URIs, JWT tokens (RFC 4648)

The custom base field on this tool supports any base from 2 to 36. Base 36 is the maximum single-character-per-digit system because it uses all 10 digits (0-9) plus all 26 letters (A-Z) of the English alphabet. Base 64 encoding, defined in RFC 4648, goes beyond this by adding lowercase letters and two punctuation characters (+, /), but it is an encoding scheme rather than a simple positional number system.

What Are Common Base Conversion Mistakes?

A few errors come up repeatedly when working with number bases, especially for programmers switching between systems:

  • Confusing octal and decimal. The C expression 010 == 10 evaluates to false because 010 is octal 8, not decimal 10. This is a classic source of bugs when parsing user input with leading zeros. JSON explicitly forbids leading zeros on numbers for this exact reason.
  • Case sensitivity in hex. Hex digits A-F are case-insensitive in almost every context. 0xFF and 0xff represent the same value (255). However, base64 IS case-sensitive - 'A' (index 0) and 'a' (index 26) are different characters in the base64 alphabet.
  • Forgetting that hex FF is 255, not 256. The maximum value of a single byte is FF (255), not 100 (which is 256 in hex). Off-by-one errors in hex are common when calculating address ranges or buffer sizes.
  • Sign representation. This converter handles unsigned (non-negative) integers. Signed integers in computers use two's complement, where the highest bit indicates the sign. The value 0xFF in an unsigned byte is 255, but in a signed byte it is -1.
  • Bit width assumptions. The number 1000 0000 in binary is 128 as an unsigned 8-bit value but -128 as a signed 8-bit value using two's complement. Always know the bit width and signedness of the values involved.

How Are Number Bases Used in Networking?

Network protocols rely heavily on different number bases. IPv4 addresses are conventionally written in decimal (192.168.1.1) but subnet masks are often analysed in binary to understand which bits identify the network vs. the host. A /24 subnet mask is 11111111.11111111.11111111.00000000 in binary, or 255.255.255.0 in decimal.

IPv6 addresses use hexadecimal exclusively. Each address is 128 bits long, written as eight groups of four hex digits separated by colons, per RFC 4291. A full IPv6 address like 2001:0db8:0000:0000:0000:ff00:0042:8329 can be shortened to 2001:db8::ff00:42:8329 by stripping leading zeros and collapsing consecutive zero groups with ::. Without hex, writing out 128 binary digits for every address would be impractical.

MAC addresses use six pairs of hex digits (e.g. A1:B2:C3:D4:E5:F6), representing 48 bits. The first three bytes (24 bits) identify the hardware manufacturer through an OUI (Organizationally Unique Identifier) assigned by the IEEE.

Practical Worked Example: RGB Colour to Binary

Web colour #3B82F6 (a medium blue) breaks down as: R = 3B (hex) = 59 (decimal) = 00111011 (binary), G = 82 (hex) = 130 (decimal) = 10000010 (binary), F6 (hex) = 246 (decimal) = 11110110 (binary). The full 24-bit binary representation is 00111011 10000010 11110110. Each colour channel occupies one byte (8 bits), and the three bytes together give 16,777,216 possible colours (256^3). The Colour Converter handles this RGB-to-hex mapping with a live preview.

For focused binary-to-decimal work with bit visualisation, the Binary to Decimal Converter has a dedicated interface. For exploring the full character table used in programming, the ASCII Table shows decimal, hex, octal, and binary values for all 128 ASCII characters.

Sources

Frequently Asked Questions

What bases does this converter support?

It supports any base from 2 to 36. The four most common bases - binary (2), octal (8), decimal (10), and hexadecimal (16) - each have dedicated fields. A custom base field lets you work with any other base in that range, using digits 0-9 and letters A-Z.

How does it handle very large numbers?

The converter uses BigInt internally, so it can handle arbitrarily large integers without losing precision. This makes it suitable for cryptographic values, large binary strings, or any number beyond the standard 64-bit integer range.

What digits are used for bases above 10?

Bases above 10 use letters after the digits 0-9. Base 11 uses 0-A, base 16 uses 0-F, and base 36 uses the full set of 0-9 plus A-Z. The reference table at the bottom shows all 36 possible digit characters and their values.

Why would I need to convert number bases?

Base conversion is common in programming (binary and hex for memory addresses, bitwise operations, colour codes), networking (IP addresses, subnet masks), digital electronics, and computer science education. Hex is also widely used for colour values in web design.

Can I convert in both directions?

Yes. Type a value into any field and all other fields update instantly. You can start from binary, decimal, hex, or any custom base and see the equivalent value in every other base simultaneously.

Link to this tool

Copy this HTML to link to this tool from your website or blog.

<a href="https://toolboxkit.io/tools/number-base-converter/" title="Number Base Converter - Free Online Tool">Try Number Base Converter on ToolboxKit.io</a>