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.
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).