How to convert between binary, decimal, hex and octal
This number base converter keeps four fields in sync: type into binary, octal, decimal or hexadecimal and the other three update instantly. It's built on JavaScript's BigInt, so it handles numbers far beyond the 2^53 limit of regular JavaScript numbers — 64-bit IDs, 128-bit values, hashes — without losing precision.
Use it to read a hex dump, check a bit mask, decode a colour value, work out Unix permissions, or debug a protocol field. Conversions run locally in your browser.
How to use it
- Type a number into whichever field matches what you have — for example
ffin the hex field or1010in the binary field. - Read the equivalent values in the other three bases.
- Copy any value. Prefixes like
0x,0band0oare optional, and hex input is case-insensitive (output is uppercase).
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
10 | 1010 | 12 | A |
255 | 11111111 | 377 | FF |
420 | 110100100 | 644 | 1A4 |
4096 | 1000000000000 | 10000 | 1000 |
65535 | 1111111111111111 | 177777 | FFFF |
How positional bases work
In base b, each digit is multiplied by a power of b according to its position from the right. Hex 1a4 is 1×16² + 10×16¹ + 4×16⁰ = 256 + 160 + 4 = 420. Binary 1010 is 8 + 0 + 2 + 0 = 10.
Hex and octal are popular because they map neatly onto bits: one hex digit is exactly 4 bits (a nibble), and one octal digit is exactly 3 bits. That's why a byte is always two hex digits (00–ff), and why Unix permissions — three bits each for owner, group and others — are written in octal.
Where you'll meet each base
- Hex — memory addresses, colour codes (
#1a4fff), byte dumps, hashes, UUIDs, Unicode code points (U+1F600), MAC addresses. - Binary — bit flags and masks, subnet masks (
255.255.255.0is 24 ones followed by 8 zeros), hardware registers. - Octal — Unix file permissions:
chmod 644isrw-r--r--(110 100 100),755isrwxr-xr-x. - Decimal — everything humans read, plus database IDs and counters.
Precision and negative numbers
JavaScript's normal Number type can only represent integers exactly up to 9,007,199,254,740,991 (2^53 − 1). Many converters silently round larger values. This one uses BigInt, so a 64-bit value like 18446744073709551615 converts exactly to FFFFFFFFFFFFFFFF.
Negative numbers are shown with a minus sign in every base (-FF), not in two's complement form. To get the two's-complement bit pattern of a negative 8-, 16-, 32- or 64-bit integer, add 2^n to it first — e.g. −1 in 8 bits is 256 − 1 = 255 = FF. Only integers are supported; fractional values aren't converted.
Related: convert byte counts between KB, MB and GB with the data size converter, or hash data with the SHA-256 generator.
Frequently asked questions
How do I convert hex to decimal?
Type the hex digits (with or without 0x) into the hex field and read the decimal field. For example FF is 255 and 1000 is 4096.
Can it convert very large numbers?
Yes. It uses BigInt arithmetic, so there's no practical size limit and no rounding — unlike converters based on regular JavaScript numbers, which lose precision above 2^53.
Does it support two's complement?
Negative values are shown with a minus sign rather than as two's complement. Add 2^n (for an n-bit integer) to a negative number to get its two's-complement representation.
Is hex case-sensitive?
No. FF, ff and Ff are the same value. Lowercase is common in code and hashes; uppercase is common in documentation and hardware datasheets.