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.

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.