Number Base Converter

Decimal, binary, hex, octal — all at once. Edit any field and the rest update instantly.

(0–9)
(0, 1)
(0–9, A–F)
(0–7)
(0–9, a–v)
(0–9, A–Z, a–z, +, /)

How the Number Base Converter Works

Type a number in any of the four fields — decimal (base 10), binary (base 2), hexadecimal (base 16), or octal (base 8) — and all other fields update instantly. The converter uses JavaScript's built-in parseInt() for parsing and number.toString() for conversion, so results are accurate up to Number.MAX_SAFE_INTEGER (2⁵³ − 1).

If you enter an invalid character for a base (for example, '2' in a binary field), an error message appears explaining what characters are allowed. Hexadecimal output is always shown in uppercase (A–F). Each field has a Copy button for quick clipboard access.

Number Bases Explained

  • Decimal (base 10): the everyday number system using digits 0–9. Each position represents a power of ten. The number 255 means 2×100 + 5×10 + 5×1.
  • Binary (base 2): uses only 0 and 1. The fundamental language of computers since all data is stored as sequences of bits (binary digits). 255 in binary is 11111111.
  • Hexadecimal (base 16): uses digits 0–9 and letters A–F. Widely used in programming, web colors (#FF5733), memory addresses, and debugging. Compact: one hex digit represents exactly 4 binary bits. 255 = FF.
  • Octal (base 8): uses digits 0–7. Historically used in computing and Unix file permissions (chmod 755 uses octal). Less common today but still appears in low-level programming. 255 in octal is 377.

Understanding Number Systems

The decimal system (base 10) uses ten distinct digits — 0 through 9. Its dominance almost certainly comes from the fact that humans have ten fingers. Each position represents a power of 10: rightmost is ones (10⁰), then tens (10¹), then hundreds (10²), and so on. When you write 347, you're really expressing 3×100 + 4×10 + 7×1. Compact and consistent — but it's just one of many valid ways to represent numbers.

Binary (base 2) uses only 0 and 1, and it's the fundamental language of all modern computers. Every processor instruction, every file on disk, every pixel on your screen is ultimately a sequence of bits. The reason is physical: electronic circuits are easiest to build with two stable states — on and off, high voltage and low voltage. A single bit stores one of two values. Eight bits form a byte, representing 2⁸ = 256 distinct values. Binary arithmetic follows the same positional rules as decimal — each position is just a power of 2 instead of 10.

Hexadecimal (base 16) uses 0–9 plus A–F. It emerged as a practical shorthand for binary: one hex digit represents exactly four binary bits (2⁴ = 16). So a full byte (8 bits) is always exactly two hex digits — making memory dumps, color codes, and error codes far more readable than long strings of 0s and 1s. Octal (base 8) uses digits 0–7 and was historically important in early computing — especially in Unix systems, where file permissions are still described with three octal digits. Knowing all four bases gives you a complete toolkit for reading technical docs, debugging code, and working with low-level systems.

Where You Encounter Different Bases

  • Binary in networking. IP addresses (IPv4) are 32-bit binary numbers divided into four 8-bit octets and displayed in decimal (e.g., 192.168.1.1). Subnet masks like 255.255.255.0 are also binary in disguise — in binary, 255 = 11111111 and 0 = 00000000. Understanding the binary representation explains why subnet masks always consist of consecutive 1s followed by consecutive 0s.
  • Hexadecimal in web design. CSS colors use the #RRGGBB format where each pair of hex digits (00–FF) encodes the intensity of red, green, and blue from 0 to 255. The color #FF0000 is pure red (red = 255, green = 0, blue = 0). Shorthand notation #RGB expands each digit to a pair, so #F30 becomes #FF3300. Modern CSS also supports rgba() but hex remains the most compact and widely used format in design tools.
  • Octal in Unix and Linux. File permissions in Unix-based systems are stored as a set of nine bits (read, write, execute for owner, group, and others). These nine bits are often expressed as three octal digits: chmod 755 gives the owner full access (7 = 4+2+1 = rwx), while group and others get read and execute only (5 = 4+1 = r-x). The octal representation maps perfectly to the three-bit groups because 2³ = 8.
  • Base64 on the web. Base64 encoding (used for data URIs, email attachments, and JWT tokens) shares the same alphabet as positional base 64 but works differently — it groups binary input into 6-bit chunks and maps each to a character. This converter handles positional base 64, not the encoding scheme. Base64 encoding increases data size by about 33% but makes binary data safe for text-based formats.

Six bases, bit-length padding, and an ASCII bridge

The converter now handles six bases instead of four. Base 32 uses Crockford's alphabet (digits 0–9 then a–v, no ambiguous I/O/L characters), which you'll encounter in Ulid identifiers and some URL-shorteners. Base 64 here is positional — digits 0–9, uppercase A–Z, lowercase a–z, plus +/ — not the Base64 encoding used for binary data in emails or JWTs. That distinction matters. A binary bit-length toggle lets you switch between 8, 16, 32, and 64-bit padding, so 7 in binary shows as 00000111 at 8 bits or 0000000000000111 at 16. Useful when you're reading memory dumps or protocol specs that expect fixed-width fields.

For decimals between 32 and 126 — the printable ASCII range — a character label appears next to the decimal field. Type 65 and you see A. Type 32 and you see the space character noted explicitly. Outside that range, the label stays hidden. Per-character keystroke filtering is active on every input: type a character that's invalid for the current base and it's blocked rather than shown as an error after the fact. What isn't here: floating-point conversion and two's-complement signed negatives.

Frequently Asked Questions

Why is hexadecimal used for web colors?
Web colors (like #FF5733) use hexadecimal because each color component — red, green, and blue — ranges from 0 to 255. In hexadecimal, 0–255 maps perfectly to 00–FF: exactly two hex digits. This makes hex codes compact and easy to read for developers. #RRGGBB uses 6 characters to encode 3 × 8 bits = 24-bit color.
What does chmod 755 mean in octal?
In Unix file permissions, chmod 755 uses three octal digits: 7 (owner: read + write + execute = 4+2+1), 5 (group: read + execute = 4+1), and 5 (others: read + execute = 4+1). Each digit is the sum of permission bits — read (4), write (2), execute (1) — expressed as a single octal digit.
What is the largest number this converter supports?
The converter supports integers up to Number.MAX_SAFE_INTEGER, which is 9,007,199,254,740,991 (2⁵³ − 1). Beyond this limit, JavaScript cannot represent integers exactly, which would produce incorrect conversions. For most practical use cases — memory addresses, color codes, permissions — this limit is more than sufficient.
How do you convert binary to decimal by hand (without a tool)?
Write out the binary number and assign powers of 2 from right to left starting at 2⁰ = 1. Multiply each binary digit (0 or 1) by its corresponding power of 2, then sum the results. For example, 1101 in binary: (1×2³) + (1×2²) + (0×2¹) + (1×2⁰) = 8 + 4 + 0 + 1 = 13. This process works for any base — substitute the base value (8 for octal, 16 for hex) and the appropriate digit values.
Why do computers use binary instead of just using decimal?
Physical reliability. Electronic circuits are most stable with two clear states — a transistor is either conducting (1) or not (0). Building a circuit that reliably distinguishes ten voltage levels is a lot harder and more error-prone than distinguishing just two. Binary also makes Boolean logic (AND, OR, NOT) trivial to implement in hardware. Early decimal computers existed — the ENIAC used decimal — but binary proved more practical at scale, and it's been the universal standard since the 1950s.

You might also need

See all tools →

Complementary tools based on what you're doing