Number Base Converter

Convert numbers between binary (base 2), octal (base 8), decimal (base 10), hexadecimal (base 16), and any custom base. Instant conversion with copy buttons.

Number Input
From Base

Frequently Asked Questions

A number base (or radix) determines how many distinct digits a numeral system uses. Base 10 (decimal) uses 0–9 and is the everyday counting system. Base 2 (binary) uses 0 and 1 and is the foundation of computing. Base 8 (octal) uses 0–7 and was common in early computing. Base 16 (hexadecimal) uses 0–9 and A–F, compactly representing bytes (2 hex digits = 1 byte).
Hexadecimal is compact and directly maps to binary: each hex digit represents exactly 4 binary bits. A byte (8 bits) is always 2 hex digits, making memory dumps, color codes, and hash values much easier to read than long binary strings. Colors in CSS (#FF5733), memory addresses (0x7fff5fbff820), and hash digests (SHA-256) are all commonly expressed in hexadecimal for human readability.
Binary uses only 0 and 1. Each position represents a power of 2: the rightmost is 2⁰ = 1, next is 2¹ = 2, then 2² = 4, 2³ = 8, etc. To convert binary to decimal, sum the powers of 2 where the digit is 1. Example: 1011 = 1×8 + 0×4 + 1×2 + 1×1 = 11. To convert decimal to binary, repeatedly divide by 2 and collect remainders from bottom to top. Computers use binary because transistors have two states: on (1) and off (0).
Octal and hexadecimal are convenient groupings of binary digits. Since 8 = 2³, each octal digit maps to exactly 3 binary bits. Since 16 = 2⁴, each hex digit maps to exactly 4 binary bits. This makes conversion between them simple: group the binary digits from the right in sets of 3 (for octal) or 4 (for hex) and convert each group. Example: binary 110101 → grouped as 110 101 = octal 65; grouped as 0011 0101 = hex 35.
The 0x prefix is a convention in programming languages (C, C++, Java, JavaScript, Python, etc.) to indicate that a number literal is in hexadecimal. For example, 0xFF is 255 in decimal. Similarly, 0b indicates binary (0b1010 = 10) and 0o or just a leading 0 (language-dependent) indicates octal (0o17 = 15). The prefix is not part of the number itself — it is just notation for the parser.
The most common method is two's complement: to negate a number, flip all bits and add 1. For 8-bit integers, +127 is 01111111 and -128 is 10000000. The most significant bit acts as a sign bit (0 = positive, 1 = negative). Two's complement is used universally in modern CPUs because it makes addition and subtraction use the same hardware circuit. This tool uses JavaScript's integers which are 53-bit precision — it does not display two's complement signed representation.
Binary (base 2): CPU instructions, file format flags, bitmasks, network subnet masks. Octal (base 8): Unix file permissions (chmod 755), some legacy protocols. Hexadecimal (base 16): Colors (#RGB), memory addresses, hashes, MAC addresses, UUIDs, byte-level data representation. Base 64: encoding binary data as text (email, JWT). Base 32: TOTP codes (authenticator apps). Base 36: URL shorteners, unique IDs using alphanumeric characters.
Base 36 uses digits 0–9 and letters A–Z (case-insensitive), giving 36 unique symbols. It is used for compact, human-readable identifiers: URL shorteners (bit.ly, t.co), unique ID generation (you can encode large numbers in fewer characters than decimal), and case-insensitive alphanumeric codes. A 10-digit decimal number fits in just 7 base-36 characters. JavaScript's Number.toString(36) and parseInt(str, 36) directly support it.
JavaScript: parseInt('ff', 16) converts hex to decimal; (255).toString(16) converts decimal to hex. Works for any base 2–36. Python: int('ff', 16), bin(255), oct(255), hex(255). PHP: base_convert('ff', 16, 10) converts between any two bases. MySQL: CONV('ff', 16, 10). Use language-native functions rather than implementing conversion manually — they are well-tested and handle edge cases correctly.
Unix permissions are stored as a 9-bit mask: 3 bits for owner (read/write/execute), 3 for group, 3 for others. Each group of 3 bits maps to one octal digit (0–7). Permission 755 means: owner = 7 (rwx = 111₂ = 7₈), group = 5 (r-x = 101₂ = 5₈), others = 5. Permission 644 means: owner = 6 (rw- = 110₂ = 6₈), group = 4 (r-- = 100₂), others = 4. This is why octal is still relevant in Unix/Linux administration despite being uncommon elsewhere in modern computing.

About This Number Base Converter

This free number base converter converts integers between binary (base 2), octal (base 8), decimal (base 10), hexadecimal (base 16), and any custom base from 2 to 36. All conversion runs in your browser using native JavaScript integer arithmetic.

When to use this tool

  • Converting hex color codes to decimal RGB values
  • Understanding binary representations of numbers
  • Working with Unix file permissions in octal
  • Converting between number systems for programming

Related Articles

In-depth guides and technical articles.

View all →
How to Read Hex Like a Debugger — Magic Bytes, Memory Dumps, and Why Byte Order Matters
Hexadecimal is a window into how computers represent data at the byte level — and once you can read it naturally, you start seeing structure in things that previously looked like noise. Here's how magic bytes identify file formats (JPEG starts with FF D8 FF, PDF with %PDF-, ZIP with PK), what hex reveals in network captures and memory dumps, the endianness problem that causes little-endian hex to read backwards, and the famous debug sentinel values like 0xDEADBEEF and 0xCAFEBABE.
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.
#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.
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.
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.