Binary, octal, decimal, and hexadecimal are all ways of writing the same number using a different number of digit symbols: base 2, 8, 10, and 16 respectively. Programmers move between them constantly: binary maps directly to how a computer stores a value, hex is a compact way to write binary data (each hex digit is exactly 4 bits), and decimal is what everyone reads.
How it works
Enter a value and tell the converter which base it's currently written in, and the converter parses it as that base internally.
Every other base is then derived by converting through decimal: the value is read into a plain number, then re-expressed in binary, octal, and hexadecimal digit symbols.
Hexadecimal uses the digits 0-9 followed by A-F for 10-15; octal uses only 0-7; binary uses only 0-1. If your input contains a character invalid for the selected base (like an "A" while "Decimal" is selected), only the valid leading digits are parsed, so double check the base selection if a result looks unexpectedly small.
A worked example
Entering 255 with "Decimal" selected converts to 11111111 in binary, 377 in octal, and FF in hexadecimal, the maximum value a single byte (8 bits) can hold.
More examples
Hex D6 is 214 in decimal, 11010110 in binary and 326 in octal. Each hex digit maps to exactly four binary digits: D is 1101 and 6 is 0110.
Common mistakes
- Reading a leading-zero number like 0755 as decimal when a language treats it as octal.
- Forgetting prefixes: 0x for hex, 0b for binary, 0o for octal.
- Mixing signed and unsigned values: 0xFF is 255 unsigned but −1 as a signed byte.
- Grouping binary digits from the left instead of the right.
Questions people ask
Why does hexadecimal use letters?
Hex is base 16, which needs 16 distinct digit symbols. After 0-9 runs out, hex continues with A (10), B (11), C (12), D (13), E (14), and F (15) so every value from 0-15 has a single-character symbol.
Why is hex so common in programming if binary is what the computer actually uses?
Each hex digit represents exactly 4 binary bits, so a byte (8 bits) is always exactly 2 hex digits. That makes hex a much more compact and readable way to write binary data: color codes, memory addresses, and byte values are almost always shown in hex rather than raw binary for this reason.
Can this convert negative numbers?
This converter handles non-negative integers. Negative numbers in binary/hex are typically represented using two's complement, which depends on a fixed bit-width (8-bit, 16-bit, 32-bit, etc.) that this general-purpose converter doesn't assume.
What's the largest number this can handle accurately?
Up to JavaScript's safe integer limit, 2^53 − 1 (about 9 quadrillion), far beyond what any manual conversion task is likely to need.
How do I convert binary to decimal by hand?
Give each digit a place value that doubles from right to left: 1, 2, 4, 8 and so on. Add the place values where the digit is 1. For 1011 that's 8 + 0 + 2 + 1 = 11.
Guides
- How Long Should a Password Be? Entropy, Length and PassphrasesEntropy measures how many guesses a random password takes, in bits. The math shows why length beats complexity, what current NIST guidance says, and how passphrases compare.
- Binary, Octal and Hexadecimal: How Number Bases WorkEvery number base works the same way; only the number of digits changes. Here is how to read binary and hex, with worked conversions.
- HEX, RGB and HSL: Three Ways to Write the Same ColorA HEX code is three numbers in base 16. RGB writes the same numbers in decimal. HSL describes the color by hue, saturation and lightness. Here is how they connect.