Free tool · no sign-up
Hex, decimal, binary and octal converter
One value in all four bases at once, exact at any width — plus the bit pattern padded to 8, 16, 32 and 64 bits, and text to and from raw bytes.
Type a value, say which base it is in, and you get the other three immediately — along with how many bits it needs and the same bit pattern padded out to a byte, a word, a 32-bit and a 64-bit register.
It is exact. Most converters run the value through the browser's ordinary number type, which stops being able to count past 9,007,199,254,740,991 — so a 16-digit hex value comes back subtly wrong with no warning. This one uses arbitrary-precision arithmetic, so a full 64-bit mask converts correctly, digit for digit.
Which base is which, and how to tell
All four bases write the same number; they differ only in how many symbols each digit may be. Prefixes exist so a program can tell them apart, and the converter accepts them whether you type them or not.
- Decimal (base 10) — digits 0-9, no prefix. What people count in.
- Hexadecimal (base 16) — digits 0-9 then a-f, written 0x1F. One hex digit is exactly four bits, so two of them are exactly one byte, which is why memory addresses, colours, hashes and MAC addresses are all hex.
- Octal (base 8) — digits 0-7, written 0o755 or just 755. Survives mainly in Unix file permissions, where each digit is one set of read/write/execute bits.
- Binary (base 2) — digits 0 and 1, written 0b1010. What the machine actually holds; useful when you need to see individual flag bits.
Why the bit width is shown separately
A number has a value, and a register has a width, and they are not the same thing. 255 needs 8 bits. Stored in a 32-bit field it is 00000000 00000000 00000000 11111111 — the same number with 24 leading zeros. That matters when you are reading a packet dump, masking flags or working out whether a value will fit in a column.
Negative numbers are shown here as a sign and a magnitude (-255 is -0xFF), which is what base conversion means. Machines usually store negatives as two's complement instead: invert every bit and add one, within a fixed width. In 8 bits -1 is 11111111; in 32 bits it is thirty-two 1s. Because the answer depends entirely on the width, quoting one without the width would be misleading, so this tool does not.
Text, bytes and the hex you find in a dump
Switch the first field to “Text to bytes” and you get the UTF-8 bytes of whatever you type, in hex, decimal and binary. Switch it to “Hex bytes to text” and a run of hex from a log line, a packet capture or a database blob is decoded back into readable text.
UTF-8 is why the byte count and the character count differ. ASCII characters take one byte each, accented Latin letters take two, most other scripts take three and emoji take four. A field that counts “characters” but measures bytes is the usual cause of a name that will not save.
Common questions
How do I convert hex to decimal by hand?
Multiply each digit by 16 raised to its position from the right, counting from zero, and add them up. 0x1F is (1 x 16) + (15 x 1) = 31. Going the other way, divide by 16 repeatedly and read the remainders backwards.
Why is my 64-bit value wrong in other converters?
Because JavaScript numbers are doubles, which hold integers exactly only up to 2^53 - 1. Above that, digits are silently rounded. This converter uses BigInt arithmetic, so a full 64-bit value is exact.
What does 0x, 0b or 0o in front of a number mean?
It tells a compiler, shell or config parser which base follows: 0x is hex, 0b is binary, 0o is octal. A bare leading zero means octal in C and in some shells, which is why 0755 and 755 can mean different numbers in different places. Paste either form here and it is handled.
Why are Unix permissions written in octal?
Because read, write and execute are three bits, and one octal digit is exactly three bits. 7 is rwx, 6 is rw-, 5 is r-x. So 755 fits the owner, group and other sets into three digits with nothing left over.
Is anything I type sent to a server?
No. Every conversion happens in your browser and nothing is transmitted. That is deliberate: hex from a dump or a token is exactly the sort of thing that should not be pasted into someone else's server log.