Number Base Converter
Convert between binary, octal, decimal, hex, and any base 2–36. All outputs update as you type. Explore bit-level values with the interactive grid, and copy code-ready literals for Python, JavaScript, C, and Rust. BigInt precision — all browser-side.
How to use
- Enter a number in the input field and select its base with the Dec / Bin / Oct / Hex buttons.
- Read all outputs — binary, octal, decimal, hex, and your custom base update simultaneously as you type.
- Toggle bits in the grid to build bitmasks or explore flag values. Each click recalculates all outputs.
- Copy as code to paste Python, JavaScript, C, or Rust integer literals directly into your source.
Frequently asked questions
How do I convert binary to decimal by hand?
Each binary digit represents a power of 2, from right to left. Multiply each bit by its positional power and sum. For 1011₂: (1×8)+(0×4)+(1×2)+(1×1) = 11₁₀. This tool does it instantly for any length number using BigInt.
What's the difference between octal and hexadecimal?
Octal uses digits 0–7 (base 8); each digit maps to exactly 3 binary bits. Hex uses 0–9 and A–F (base 16); each hex digit maps to 4 binary bits. Octal is used in Unix permissions (chmod 755). Hex dominates today because a byte (8 bits) = exactly two hex digits, making memory addresses, color codes, and protocols compact.
Why do programmers use hexadecimal?
Hex is a power-of-2 base (2⁴=16), so each hex digit maps to 4 binary bits. A 32-bit address fits in 8 hex characters vs. 32 binary digits. Hex appears in memory addresses, RGB colors (#RRGGBB), assembly listings, crypto hashes, and debug dumps — compact, unambiguous, and easy to read.
What's two's complement and does this tool show it?
Two's complement is how computers represent negative integers: flip all bits, then add 1. In 8-bit, -1 = 11111111 (255 unsigned). This tool works with non-negative unsigned integers. To see a two's complement bit pattern, enter the unsigned form — e.g., 255 to see the 8-bit pattern for -1.
What's the max base this converter supports, and why 36?
Bases 2–36. Base 36 is the practical max with the standard digit alphabet: 0–9 (10) plus A–Z (26) = 36 unique symbols. Base 36 is popular for URL shorteners and compact identifiers. JavaScript's parseInt() and Number.toString() also cap at 36.
How do I read the bit grid?
Each cell is one bit. Bit 0 (rightmost) is the least significant; the leftmost is the most significant. Blue/filled = 1, empty = 0. Click any bit to toggle it — all outputs recalculate instantly. Useful for bitmasks, flag registers, and visualizing bitwise AND/OR/XOR results.
What are the 0b, 0o, and 0x literal prefixes?
0b = binary (0b1011), 0o = octal (0o13), 0x = hexadecimal (0xB). These work in Python, JavaScript, C, Rust, Go, and Swift. The copy-as-code panel generates the correct prefix and digits for each language automatically.
Can this handle numbers larger than 64 bits?
Yes — the tool uses JavaScript's native BigInt, supporting integers of arbitrary precision. Paste a 256-bit number from a cryptographic context and see all bases. Standard JS numbers lose precision above 2⁵³; BigInt avoids this entirely.
Is my input sent to a server?
No. All conversion runs locally in your browser. Open DevTools → Network and type — zero outbound requests from the tool itself. It is a single HTML file with no backend.
How do I convert a fraction between bases?
Multiply the fractional part by the target base, take the integer portion as the next digit, and repeat with the remainder. 0.1₁₀ in binary = 0.0001100110011… (repeating). This tool handles non-negative integers only; apply the algorithm manually for fractions.
Examples
Unix file permissions — chmod 755
Each octal digit = 3 permission bits. 755 means owner=rwx, group=r-x, other=r-x.
755₈ = 111 101 101₂ 7 = 111 (r+w+x = 4+2+1) 5 = 101 (r+x = 4+0+1) 5 = 101 (r+x = 4+0+1) Dec: 493 Hex: 0x1ED
IPv4 subnet mask — /24
255.255.255.0 is a /24 mask: 24 consecutive 1-bits then 8 zero-bits.
255 → 0xFF → 11111111₂ 0 → 0x00 → 00000000₂ Full 32-bit mask: 0xFF FF FF 00 = 4294967040 decimal Binary: 24 ones + 8 zeros
Bitmask flags in C / Rust
Define flags as powers of 2, combine with OR, test with AND.
READ = 0b0001; // 1 WRITE = 0b0010; // 2 EXECUTE = 0b0100; // 4 perms = READ | WRITE; // 3 // 3 = 0b0011 can_read = perms & READ; // 1
About number base conversion
Every integer can be expressed in any positional numeral system — a number base where digits represent multiples of successive powers of that base. Decimal (base 10) is the universal human counting system, rooted in ten fingers. Binary (base 2) is the native language of digital electronics: a transistor is either on (1) or off (0). Octal (base 8) and hexadecimal (base 16) are compact human-readable representations of binary data that programmers use daily.
Converting between bases: parse each digit of the source string as a value (A–Z represent 10–35), multiply by its positional power of the source base, sum to get the integer, then express that integer in the target base by repeated modulo and division. JavaScript's BigInt type extends this to numbers of arbitrary size, eliminating precision loss that occurs with IEEE 754 floating-point above 2⁵³.
The bit grid provides a mental model for bitwise operations. Logical AND keeps only bits set in both operands — used to extract specific bit fields (masking). OR sets bits present in either — used to combine flags. XOR flips bits that differ — used to toggle bits and detect changes. NOT flips every bit — used for complement arithmetic. Understanding the bit pattern of a number makes these operations intuitive rather than abstract.
Hexadecimal dominates low-level programming because one hex digit maps to exactly 4 binary bits, and a byte (8 bits) is exactly two hex digits. Memory addresses, color values (#RRGGBB), network packets, cryptographic hashes, CPU registers, and ELF binary headers are all naturally expressed in hex. A 64-bit address like 0x7fff5fbff8a0 is 16 hex characters — far more readable than 64 binary digits or a large decimal number.
Octal survives primarily in Unix file permissions. The chmod command takes three octal digits, each representing three permission bits: read=4, write=2, execute=1. chmod 755 sets owner to 7 (rwx), group to 5 (r-x), other to 5 (r-x). Octal was also common on PDP-10 and PDP-11 minicomputers, where 3-bit groupings aligned naturally with 12-bit and 36-bit word sizes.
Arbitrary bases appear throughout encoding and computing. Base 36 (digits 0–9 plus A–Z) is used in URL shorteners, license keys, and compact serial numbers. Base 32 (RFC 4648, using A–Z2–7) encodes binary data in case-insensitive ASCII. Base 64 (using A–Z, a–z, 0–9, +, /) is the standard for encoding binary data in HTTP, MIME, and JSON. This tool covers bases 2–36 using the standard digit alphabet — sufficient for all common programming and engineering use cases.
All conversions run entirely in your browser. No number you enter is transmitted anywhere. The tool works offline after the initial page load and produces identical results to parseInt(str, base) and BigInt operations in any modern JavaScript runtime.