The Binary/Hex Converter converts numbers between decimal (base 10), binary (base 2), hexadecimal (base 16), and octal (base 8) number systems โ all fields update simultaneously as you type in any one of them.
Binary / Hex Converter
Convert numbers between binary, decimal, hexadecimal, and octal.
How to Use This Calculator
- Type a number in any field (decimal, binary, hex, or octal).
- All other fields update automatically.
- Click Reset to clear all fields.
The Four Number Systems Explained
Decimal (Base 10) is the everyday number system using digits 0โ9. Each position represents a power of 10.
Binary (Base 2) uses only 0 and 1. It’s the native language of computers because electronic circuits have two states: on (1) and off (0). Every file, image, and program on your computer is ultimately stored as binary.
Hexadecimal (Base 16) uses digits 0โ9 plus letters AโF. One hex digit represents exactly 4 binary bits (a “nibble”), and two hex digits represent a byte โ making it a compact and human-readable shorthand for binary. Memory addresses, color codes (#FF5733), and file hashes are expressed in hexadecimal.
Octal (Base 8) uses digits 0โ7. It’s less common today but historically used in Unix/Linux file permissions (e.g., chmod 755).
Frequently Asked Questions
What does “0x” prefix mean?
“0x” is a convention indicating a hexadecimal number in programming languages (C, Python, JavaScript, etc.). For example, 0xFF means 255 in decimal. This calculator accepts hex input without the prefix.
What is the largest number this converter handles?
JavaScript’s Number type can exactly represent integers up to 2^53 โ 1 (9,007,199,254,740,991). For larger numbers, the binary/hex representation may lose precision.
Number System Reference
| Decimal | Binary | Hex |
|---|---|---|
| 10 | 1010 | A |
| 15 | 1111 | F |
| 255 | 11111111 | FF |
| 256 | 100000000 | 100 |
Why Programmers Use Binary and Hex
Computers store everything as binary (base-2) โ combinations of 0s and 1s that map directly to the on/off state of transistors. Binary is precise but verbose, so developers use hexadecimal (base-16) as a compact shorthand: a single hex digit represents exactly four binary digits (a “nibble”), and two hex digits represent one byte (0โ255). That’s why colors in web design are written as hex (#FF8800) and memory addresses are shown in hex.
How Place Value Works
In decimal, each position is a power of 10. In binary, each position is a power of 2 (1, 2, 4, 8, 16โฆ), and in hex each position is a power of 16. To convert binary to decimal, add up the place values wherever there is a 1: 1010 = 8 + 0 + 2 + 0 = 10. The calculator handles all of this instantly in both directions.
How it works
Each conversion uses JavaScript's built-in integer base-conversion: toString(base) converts from decimal to any base, and parseInt(string, base) converts from any base back to decimal. All four fields share the same underlying decimal integer value.Formula
Decimal to Binary: n.toString(2). Binary to Decimal: parseInt(s,2). Decimal to Hex: n.toString(16). Hex to Decimal: parseInt(s,16).