Number base converter

Binary, octal, decimal and hex in one place, plus text to UTF-8 binary and back.

Binary
Octal
Decimal
Hex

Four ways to write the same number

Binary (base 2), octal (base 8), decimal (base 10) and hexadecimal (base 16) are all positional systems: each digit is worth its face value multiplied by a power of the base, rising from right to left. The number itself never changes, only the costume it wears.

value = d₂ × base² + d₁ × base + d₀  (and so on for longer numbers)

So binary 1111 is 8 + 4 + 2 + 1 = 15, which octal writes as 17, and hex writes as F using the letters A to F for the values ten to fifteen. The converter accepts common prefixes on input (0b, 0o, 0x) and uses BigInt arithmetic throughout, so numbers of any size convert exactly with no rounding, well beyond the point where ordinary JavaScript numbers lose precision.

Worked examples

2026 in the other bases
binary 11111101010  ·  octal 3752  ·  hex 7EA (7×256 + 14×16 + 10 = 1792 + 224 + 10 = 2026)
Hex FF as a byte
FF = 15×16 + 15 = 255  ·  binary 11111111  ·  octal 377. One byte, fully lit.
"Hopi" as UTF-8 binary
01001000 01101111 01110000 01101001 (the bytes 72, 111, 112, 105)

Where each base earns its keep

Hex is the everyday one. Because a single hex digit is exactly four bits, a byte is always two hex digits, which is why colour codes (#FF6B35), MAC addresses, memory dumps and hash outputs all speak hex. Octal survives mainly in Unix file permissions: chmod 755 is really three octal digits, each unpacking to three permission bits (rwx r-x r-x). Binary is what the machine actually stores, and reading it directly is the quickest way to understand bit flags, masks and why 255 is such a popular ceiling. Decimal, of course, is for humans.

Converting between them fluently is one of those small skills that pays off constantly in debugging: a mysterious 0x7EA in a log, a permissions bug, a colour that needs darkening by exactly one bit's worth.

There is also a handy shortcut worth knowing. Because 16 is 2 to the power 4, converting between hex and binary needs no arithmetic at all: replace each hex digit with its 4-bit pattern and you are done. 7EA becomes 0111 1110 1010, and dropping the leading zero gives the 11111101010 from the example above. Octal works the same trick with 3-bit groups.

Text to binary, via UTF-8

The second mode answers a different question: what do characters look like as bytes? Text is encoded to UTF-8, the encoding used by almost the entire web, and each byte is shown as an 8-digit octet. Plain English letters and digits take one byte each, so Hi becomes 01001000 01101001. Anything beyond basic ASCII takes more: £ is two bytes (11000010 10100011), and most emoji take four. Paste octets back in, and the tool decodes them to text, flagging anything that is not a valid UTF-8 sequence rather than guessing.

Everything runs in your browser. Nothing you type or paste is uploaded, so values from private code, configs and logs stay on your machine.

Frequently asked questions

How do I convert decimal to binary by hand?

Divide by 2 repeatedly and keep the remainders. For 13: 13 divided by 2 is 6 remainder 1, then 3 remainder 0, then 1 remainder 1, then 0 remainder 1. Read the remainders bottom to top and you get 1101.

Why do programmers use hexadecimal?

One hex digit represents exactly four bits, so a byte is always two hex digits. That makes hex a compact, lossless shorthand for binary: 11111111 becomes FF. You see it in colour codes, memory addresses, MAC addresses and hash outputs.

How large a number can the converter handle?

Effectively unlimited. It uses JavaScript's BigInt arithmetic, which works with whole numbers of any size, so values far beyond the usual 64-bit ceiling convert exactly with no rounding.

How does text to binary work?

Each character is encoded as UTF-8 bytes and each byte is shown as an 8-digit binary octet. Plain English letters take one octet each, so Hi becomes 01001000 01101001, while accented characters, symbols and emoji take two to four octets.

Is anything I type uploaded?

No. All conversion happens in your browser with JavaScript, and nothing is sent to a server. That makes it safe to use with values from private code, logs or documents.

Related tools