Base Converter
Enter a number to convert.
A number base converter translates integers between different positional numeral systems — binary (base 2), octal (base 8), decimal (base 10), hexadecimal (base 16), and any custom base up to 36. Each base uses a fixed set of unique digits: binary uses 0–1, hex uses 0–9 plus A–F. Every modern programming language provides built-in functions for base conversion.
Number Base Converter — Binary, Octal, Decimal, Hex
How it works
Last updated: November 2026A number base (radix) defines how many unique digits a number system uses. This tool converts any integer between the four standard programming bases — binary (2), octal (8), decimal (10), hexadecimal (16) — and any custom base from 2 to 36.
Select the input base, type your number, and all conversions appear instantly. Common prefixes are automatically stripped: 0x for hex, 0b for binary, 0o for octal. Binary output is grouped into 4-bit nibbles for readability. Everything runs in your browser — no data is sent anywhere.
Base Reference
| Base | Name | Digits | Common use |
|---|---|---|---|
| 2 | Binary | 0, 1 | CPU instructions, bitmasks, bitwise operations |
| 8 | Octal | 0–7 | Unix file permissions (chmod 755) |
| 10 | Decimal | 0–9 | Human-readable numbers, most APIs |
| 16 | Hexadecimal | 0–9, A–F | Memory addresses, colour codes, byte values |
| 32 | Base32 | 0–9, A–V | Crockford encoding, Geohash |
| 36 | Base36 | 0–9, A–Z | URL shorteners, compact IDs |
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 0 | 0000 | 0 | 0 |
| 10 | 0000 1010 | 12 | A |
| 15 | 0000 1111 | 17 | F |
| 16 | 0001 0000 | 20 | 10 |
| 255 | 1111 1111 | 377 | FF |
| 65535 | 1111 1111 1111 1111 | 177777 | FFFF |
Tips & Tricks
1 hex digit = 4 binary bits exactly
Each hex digit maps to exactly one 4-bit nibble: F=1111, A=1010, 5=0101. You can convert any hex value to binary (and back) mentally by translating digit by digit — no calculation needed. This is why hex is the standard notation for byte-level data.
Unix permissions are 3-digit octal
chmod 755 means rwxr-xr-x. Each digit is 3 bits: owner=7 (111=rwx), group=5 (101=r-x), others=5 (101=r-x). Octal is natural here because 3 bits per digit match the 3-bit permission groups exactly.
Bitmasks are easier to read in hex
The bitmask 0x0F (keep lower nibble) is immediately readable as 00001111 in binary. Working with masks in decimal (15) requires mental conversion. Always use hex constants for bitmasks in code — value & 0xFF not value & 255.
Be careful with leading zeros in C/Python 2
In C and Python 2, an integer literal starting with 0 (like 0755) is octal, not decimal. This is a classic bug: int x = 010; in C equals 8, not 10. Python 3 fixed this by requiring the explicit 0o prefix.
Hex colour codes are 3 bytes packed
#FF5733 is FF=255 (red), 57=87 (green), 33=51 (blue). The shorthand #F53 expands each digit: FF=255, 55=85, 33=51. Use this tool to explore the decimal values of any CSS colour's RGB channels.
Base 36 is the most compact alphanumeric encoding
Base 36 uses all 10 digits plus 26 letters (A–Z), making it the highest base that uses only standard alphanumeric characters. It's used by URL shorteners and ID generators that need compact, case-insensitive identifiers. The number 1,000,000 in base 36 is LFLS — just 4 characters.
Code Examples
JavaScript / Node.js
// JavaScript / Node.js — built-in conversion
const n = 255;
console.log(n.toString(2)); // '11111111' (binary)
console.log(n.toString(8)); // '377' (octal)
console.log(n.toString(16)); // 'ff' (hex)
// Parse from any base
parseInt('ff', 16); // 255
parseInt('11111111', 2); // 255
parseInt('377', 8); // 255
// Hex with leading zeros (useful for colour codes)
n.toString(16).padStart(2, '0').toUpperCase(); // 'FF' Python
# Python — built-in conversion
n = 255
bin(n) # '0b11111111'
oct(n) # '0o377'
hex(n) # '0xff'
# Parse from any base
int('ff', 16) # 255
int('11111111', 2) # 255
int('377', 8) # 255
# Format as fixed-width hex (e.g. for RGB colours)
format(255, '02X') # 'FF'
format(255, '08b') # '11111111' (8-bit padded binary) Bash
# Bash — using printf and bc printf '%d\n' 0xFF # hex to decimal: 255 printf '%x\n' 255 # decimal to hex: ff printf '%o\n' 255 # decimal to octal: 377 # bc — arbitrary base conversion echo "obase=2; 255" | bc # 11111111 (decimal to binary) echo "ibase=16; FF" | bc # 255 (hex to decimal) echo "ibase=2; obase=16; 11111111" | bc # FF (binary to hex)
Frequently Asked Questions
- What is a number base?
- A number base (radix) defines how many unique digits are used. Base 10 uses 0–9, base 2 uses 0–1, base 16 uses 0–9 plus A–F. Computers operate natively in binary (base 2); hex is used as a compact human-readable shorthand. The concept of positional notation means the value of each digit depends on its position: in decimal 255, the leftmost 2 represents 200. In binary 11111111, every bit position from 2⁰ to 2⁷ is set — all eight bits equal 1 — so the total is 128+64+32+16+8+4+2+1 = 255. In hexadecimal that same value is FF — just two characters — which is why hex is the preferred notation for byte-level data in networking protocols, colour codes, and memory debugging. Base 36, using 0–9 plus A–Z, is the highest base representable with standard alphanumeric characters.
- How do you convert hex to decimal?
- Multiply each digit by 16 raised to its position (right to left, starting at 0). FF = (15 × 16) + (15 × 1) = 255. In code:
parseInt('FF', 16)in JavaScript orint('FF', 16)in Python. For multi-character hex values like1A3F, the calculation is (1 × 16³) + (10 × 16²) + (3 × 16¹) + (15 × 16⁰) = 4096 + 2560 + 48 + 15 = 6719. In practice you never need to do this by hand — every modern language provides a built-in parser. In JavaScriptparseInt('1A3F', 16)returns 6719; in Pythonint('1A3F', 16)returns the same. For formatting back to hex with a fixed width, usen.toString(16).padStart(4,'0').toUpperCase()in JavaScript orformat(n, '04X')in Python. - How do you convert binary to decimal?
- Multiply each bit by 2 raised to its position. 11111111 = 128+64+32+16+8+4+2+1 = 255. In code:
parseInt('11111111', 2)in JavaScript orint('11111111', 2)in Python. The position of each bit starts at 0 on the right. So for the binary number 1010 the calculation is (1 × 2³) + (0 × 2²) + (1 × 2¹) + (0 × 2⁰) = 8 + 0 + 2 + 0 = 10. This positional weighting is identical to decimal — the difference is only the base. A practical shortcut: rather than computing each power of 2, convert through hex. Split the binary into groups of 4 bits from the right, convert each nibble to its hex digit (1010 = A), then convert the hex to decimal usingparseInt. For 8-bit values this mental arithmetic is fast once the nibble-to-hex table is memorised. - How do you convert decimal to binary?
- Divide by 2 repeatedly, record remainders from bottom to top. In code:
(255).toString(2)in JavaScript orbin(255)in Python (returns '0b11111111'). To illustrate manually: 255 ÷ 2 = 127 remainder 1, 127 ÷ 2 = 63 remainder 1, 63 ÷ 2 = 31 remainder 1, and so on. Reading the remainders from last to first gives 11111111. When working in Python,bin()always prepends0b; strip it withbin(255)[2:]if you need the raw digit string. For zero-padded output to a fixed bit width, useformat(255, '08b')which produces11111111(8-bit padded). In JavaScript, use(255).toString(2).padStart(8,'0')for the same result. - What is hexadecimal used for in programming?
- Hex is used for memory addresses, colour codes (#FF5733), bitmasks (0x0F), file magic numbers, and byte-level protocol debugging. Each hex digit maps to exactly 4 binary bits, making it 4× more compact than binary with no information loss. Memory addresses in a 64-bit system like
0x7fff5fbff4a0would be a 46-character binary string if written in base 2 — clearly unworkable for debugging. CSS colour codes pack three 8-bit RGB channels into 6 hex digits:#FF5733means red=255, green=87, blue=51. File format magic numbers also rely on hex: a PNG file starts with the bytes89 50 4E 47, which in ASCII decodes to .PNG. Bitmask operations likevalue & 0xFFare far more readable in hex than their decimal equivalents. - What does 0x mean in programming?
- The
0xprefix marks a hexadecimal literal.0xFF= 255,0x1F= 31. The convention is from C and used in C, C++, C#, Java, JavaScript, Python, and most other languages. Python also uses0bfor binary and0ofor octal. The0xprefix was originally chosen in C because0already signalled an octal literal, so thex(from "hexadecimal") was added to distinguish the two. In JavaScript,0xFF === 255evaluates totruebecause the engine parses them to the same numeric value. Important caveat: in Python 2, the prefix0alone (like0755) produced an octal integer literal, a common source of bugs. Python 3 requires the explicit0oprefix and raises a SyntaxError for the old form. - What is octal used for?
- Octal (base 8) is used mainly in Unix/Linux file permissions:
chmod 755where 7=rwx, 5=r-x, 5=r-x. Each octal digit represents exactly 3 binary bits — matching the 3-bit permission structure (read/write/execute) perfectly. The three octal digits in a Unix permission string encode owner, group, and others respectively. The value 7 (binary 111) means all three permission bits are set (read + write + execute). The value 5 (binary 101) means read and execute but not write. The value 4 (binary 100) means read-only. Sochmod 644gives owner read-write (110) and group/others read-only (100). Outside of Unix permissions, octal is rarely used in modern programming — Python 3, Go, and other languages still support octal literals (via0oprefix) but hex is preferred for all other byte-level work. - How do I convert hex to binary?
- Each hex digit maps directly to 4 bits: 0=0000, 1=0001, ..., A=1010, B=1011, C=1100, D=1101, E=1110, F=1111. FF in binary is 1111 1111. Convert digit-by-digit — no arithmetic needed. This one-to-one nibble mapping is what makes hex the preferred notation for binary data: the hex string
DEADBEEFimmediately encodes to binary by translating each of the 8 hex digits to its 4-bit pattern, giving a 32-bit value. For debugging network packet captures, TLS handshake records, or USB protocol traces, engineers read hex dumps and mentally translate individual nibbles to binary to check individual bit flags. Memorising the 16-entry table (0–F) is therefore a standard skill for anyone working at the binary level. Code-wise: in Pythonbin(int('FF', 16))converts hex to binary in one step. - What is the difference between 8-bit, 16-bit, and 32-bit numbers?
- 8-bit stores 0–255 (2 hex digits: FF). 16-bit stores 0–65,535 (4 hex digits: FFFF). 32-bit stores 0–4,294,967,295 (8 hex digits: FFFFFFFF). These boundaries appear in pixel colour channels (8-bit), port numbers (16-bit), IPv4 addresses (32-bit), and Unix timestamps (32-bit, hence Y2K38). For signed integers, one bit is used for the sign, leaving one fewer bit for magnitude: a signed 8-bit integer ranges from -128 to 127, a signed 16-bit from -32,768 to 32,767. The Y2K38 problem (also called the Unix Epoch Overflow) occurs because Unix timestamps are stored as a signed 32-bit integer counting seconds since 1970-01-01 — it overflows on 2038-01-19 03:14:07 UTC. Modern systems use 64-bit timestamps, which will not overflow for approximately 292 billion years. IPv4 addresses are four 8-bit octets written in dotted-decimal: 192.168.1.1 is
0xC0A80101in hex. - Is my data sent to a server?
- No. All conversion runs in your browser using JavaScript's
parseInt()andNumber.prototype.toString(). No data is sent anywhere. The converter works entirely offline once the page has loaded — you can disconnect from the internet and continue converting numbers without any interruption. This also means the tool is safe to use with internal numeric values such as memory addresses from a production system debugger, private encryption keys in numeric form, or any other sensitive data you would not want transmitted over a network. No account, sign-up, or analytics consent is required. You can verify the absence of outbound requests by opening your browser's DevTools Network tab while typing a number to convert.
Related Tools
Other free developer tools available on DevFormatter.
Hash Generator
Generate MD5, SHA-1, SHA-256, SHA-384 and SHA-512 hashes. Output is in hexadecimal.
UUID Generator
Generate UUID v4, v7 and nil UUIDs — all represented as hex with hyphens.
JWT Decoder
Decode JWT tokens and inspect header and payload claims in your browser.
JSON Formatter
Format, validate, and minify JSON. Sort keys, find duplicates, and explore with Tree view.