Number Base Converter

Convert numbers between Binary (base 2), Octal (base 8), Decimal (base 10), Hexadecimal (base 16), and any custom base from 2 to 36. All client-side.

Frequently Asked Questions

A number base (or radix) defines how many unique digits are used to represent numbers. Base 10 (decimal) uses digits 0–9. Base 2 (binary) uses only 0 and 1. Base 16 (hexadecimal) uses 0–9 and A–F. Every positive integer can be uniquely expressed in any base ≥ 2.

Hexadecimal is a compact way to represent binary data. One hex digit maps exactly to 4 bits (a nibble), so a byte (8 bits) is always two hex digits. This makes reading memory addresses, colors, byte streams, and bitfields much easier than reading long binary strings.

Computers use binary because digital circuits have two stable electrical states: on (1) and off (0). Transistors act as switches that are either conducting or not conducting, making base-2 the natural language of hardware. Representing more than two states reliably in an electrical circuit would require precise voltage levels that are easily disrupted by noise. Every number, text character, image, and program stored in a computer is ultimately a sequence of 1s and 0s.

Unix file permissions use three octal digits — one each for owner, group, and others. Each digit represents three permission bits: read (4), write (2), execute (1). So chmod 755 means owner gets 7 (4+2+1 = rwx), group gets 5 (4+0+1 = r-x), others get 5 (r-x). Octal maps perfectly to 3-bit groups, making it a compact notation for the 9-bit permission field. Convert 755 from octal to binary to see all nine bits explicitly: 111 101 101.

Use repeated division by 2: divide the number by 2, record the remainder (0 or 1), then divide the quotient again. Read the remainders in reverse order. For example, to convert 13: 13÷2=6 r1, 6÷2=3 r0, 3÷2=1 r1, 1÷2=0 r1. Reading remainders bottom-up: 1101. Verify: 8+4+0+1 = 13. The same technique works for any base — divide by the target base and read remainders in reverse.

Two's complement is the standard method CPUs use to represent negative integers in binary. To negate a number: invert all bits, then add 1. For example, in 8-bit: 5 is 00000101; invert → 11111010; add 1 → 11111011 = −5. The most significant bit acts as the sign bit (1 = negative). Two's complement allows addition and subtraction to work with the same hardware circuit for both positive and negative numbers — a key reason it is universally used.

BCD (Binary Coded Decimal) encodes each decimal digit (0–9) separately as a 4-bit binary group, rather than converting the entire number to binary. For example, the decimal number 42 in BCD is 0100 0010 (4 = 0100, 2 = 0010). BCD avoids the floating-point rounding errors of binary arithmetic for decimal fractions, making it ideal for financial calculations, cash registers, and accounting systems where exact cent values must be preserved. SQL's DECIMAL type and Java's BigDecimal internally use BCD-like representations.

Base-64 is the most common encoding for transmitting binary data (images, files, certificates) in text-safe contexts: email attachments (MIME), data URLs (data:image/png;base64,...), and JWT tokens all use base-64. It encodes 3 bytes into 4 printable ASCII characters (~33% size increase). Base-32 uses only uppercase letters and digits 2–7, avoiding ambiguous characters (0, 1, O, l) — making it human-readable and used for TOTP secret keys (two-factor auth), Crockford encoding, and some geohash systems.

Yes. The Babylonians used base-60 (sexagesimal), which is why we have 60 seconds in a minute, 60 minutes in an hour, and 360 degrees in a circle — all legacies of Babylonian mathematics. The Maya used base-20 (vigesimal), likely because they counted with both fingers and toes. The Sumerians also used base-60. Base-12 (duodecimal) survives in the 12 inches of a foot, 12 hours on a clock face, and 12 items in a dozen — valued because 12 is divisible by 2, 3, 4, and 6.

CSS hex colors like #FF5733 encode the red, green, and blue channels as three consecutive byte pairs: FF = red (255), 57 = green (87), 33 = blue (51). Each byte ranges from 00 (0) to FF (255). An optional 4th byte (#FF5733CC) controls alpha/opacity where CC hex = 204 decimal ≈ 80% opaque. The shorthand form #F53 expands each digit to a doubled pair (#FF5533). Converting the hex pairs to decimal gives you the equivalent rgb(255, 87, 51) CSS value.

About This Number Base Converter

This free number base converter converts integers between binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16). Enter a value in any base and all others update instantly.

Understanding positional notation is fundamental in computer science — binary maps directly to hardware logic, hexadecimal is used in colour codes and memory addresses, and octal appears in Unix file permissions.

When to use this tool

  • Converting hex colour codes to decimal RGB values
  • Reading binary or hex data from network packets and memory
  • Understanding Unix chmod permission bits expressed in octal
  • Learning positional notation across number bases

Standards & References

How Number Base Conversion Works

Any positive integer has a unique representation in every base ≥ 2. Conversion is a two-step process using the target base as a pivot.

Parse Input

parseInt(input, fromBase) interprets the digit string in the source base and returns a native JavaScript integer (internally base-10). Non-digit characters for the chosen base immediately produce NaN.

Convert to All Bases

number.toString(toBase) serializes the integer value in the requested base. The same integer value is passed to each toString() call — binary, octal, decimal, and hex results are generated simultaneously.

Custom Bases (2–36)

JavaScript's parseInt and toString support any base from 2 to 36. Bases above 10 use letters: base 16 uses A–F, base 36 uses A–Z (covering all alphanumeric digits).

Common Use Cases

Memory Addresses & Registers

Debuggers and CPU documentation display memory addresses in hex. Converting to decimal or binary helps understand the address space layout, alignment requirements, and offsets.

Unix File Permissions

Unix permissions like chmod 755 are octal. Converting to binary reveals the exact read/write/execute bits for owner, group, and others: 111 101 101 — each 3-bit group maps directly to rwx.

Web Color Values

CSS hex colors like #3d85c8 are three hex byte pairs. Converting each pair (3d, 85, c8) to decimal gives the RGB values (61, 133, 200) used in rgb() and rgba() CSS functions.

Bitfield Operations

Feature flags, bitmasks, and network protocol fields are easiest to understand in binary. Enter a decimal or hex bitmask and instantly see which bits are set without manual calculation.

IP Subnet & Network Math

Subnet masks are binary patterns (e.g., /24 = 24 ones followed by 8 zeros). Converting a subnet mask or IP address to binary makes CIDR calculations and host range math visually clear.

Computer Science Education

Understanding base conversion is foundational to computer science. Use this tool to check manual calculations, explore how the same number looks in different bases, or teach positional notation interactively.

Related Articles

View all articles
IEEE 754 Floating-Point: Why 0.1 + 0.2 ≠ 0.3 and What to Use for Financial Calculations

IEEE 754 Floating-Point: Why 0.1 + 0.2 ≠ 0.3 and What to Use for Financial Calculations

0.1 + 0.2 ≠ 0.3 in nearly every programming language — because 0.1 can't be represented exactly in binary. Here's the IEEE 754 bit structure (sign, exponent, mantissa), special values (NaN, Infinity, -0), why integers above 2^53 lose precision in JavaScript, and why financial code should never use floats.

Jun 15, 2026
#FF5733, 00:1A:2B:3C:4D:5E, and IPv6: Three Everyday Hex Formats, Three Different Reasons for Hex

#FF5733, 00:1A:2B:3C:4D:5E, and IPv6: Three Everyday Hex Formats, Three Different Reasons for Hex

Color codes, MAC addresses, and IPv6 addresses all use hexadecimal — but for different reasons rooted in what each format actually represents. Here's how hex's "two digits per byte" property makes color codes' three-channel structure visible at a glance, why MAC addresses' hex grouping aligns with manufacturer-ID lookups, why IPv6's 128-bit addresses would be unwieldy in decimal, and how the "::" shorthand compresses runs of zero-groups.

Jun 15, 2026
Bit Manipulation and Bitmasks: From Unix Permissions to Feature Flags

Bit Manipulation and Bitmasks: From Unix Permissions to Feature Flags

Bit manipulation is where number bases become practical: Unix permissions, feature flags, IP subnetting, and protocol fields all use bitmasks. Here's how AND, OR, XOR, and shifts work, with real examples from file permissions and flag systems.

Jun 9, 2026
Negative Numbers, Overflow, and What Hex Reveals About Your Data

Negative Numbers, Overflow, and What Hex Reveals About Your Data

Most developers can convert hex to decimal — but two's complement, signed overflow, and bit-width boundaries are where base conversion becomes genuinely useful for debugging real problems.

Jun 7, 2026
Number Base Converter — Binary, Octal, Decimal & Hex Explained

Number Base Converter — Binary, Octal, Decimal & Hex Explained

Learn how binary, octal, decimal, and hexadecimal number systems work, when each is used in programming, and how to convert between them instantly with a free number base converter.

Jun 6, 2026