Skip to content

Encoders & Crypto

Hex / Binary / Octal Converter

Convert between hex, binary, octal and decimal.

Runs in your browser

From the byte to the hex digit, in five readings.

Bytes are bytes. The base is just the lens you read them through.

Understanding number bases

Same number, different alphabet.

Binary, octal, decimal, hexadecimal — different ways of writing the same quantity, picked for what humans want to see.

What a base is.

A positional number system is a base, an alphabet of digits, and a place-value rule: each digit is multiplied by the base raised to its position from the right. Decimal is base ten because we have ten digits and grew up counting on fingers. There's no mathematical fact that makes ten special — only a biological one.

123₁₀ = 1·10² + 2·10¹ + 3·10⁰

Why computers count in twos.

Transistors have two reliable states — on or off, high voltage or low. Anything more would need finer thresholds and more chances for noise to flip a bit. So the natural base of digital hardware is two, and every other base programmers use (octal, hex) is a shorthand for binary. Three binary digits map cleanly to one octal digit; four map to one hex digit. The chip thinks in binary; the human reads in hex.

A worked conversion.

Take the decimal number 255 — the largest single byte. In binary it's eight ones (11111111); in hex it's two F's (FF); in octal three sevens (377). They're the same quantity wearing different clothes. Hex packs the most information per character of the four, which is why memory dumps, colour codes and hashes show up in hex.

255 in four bases

Same number, four alphabets

Decimal counts in tens; hex counts in sixteens; binary in twos.

255₁₀ = FF₁₆ = 11111111₂ = 377₈

= all the same byte

Why colours are hex.

A typical sRGB colour packs three channels of eight bits each, for a total of 24 bits. That's exactly six hex digits — two per channel, max value FF. Decimal would take nine digits and read worse. Binary would take twenty-four. Hex sits at the human-friendly sweet spot for byte-aligned values, which is why every CSS reference, Photoshop swatch and design system uses it.

Reading binary fluently.

A nibble is four bits — exactly one hex digit. Memorise the sixteen nibbles (0000 = 0, 0001 = 1, … 1111 = F) and you can read any binary number by chunking it from the right. Bitwise tricks (masks, shifts, flags) become much easier once the binary picture in your head matches the hex on the page.

Octal is the awkward one.

Octal pre-dates the byte. PDP-11 instructions were 16 bits and split nicely into six octal digits (with two left over for opcode bits), and Unix file permissions still print octal because three bits per digit matches read/write/execute exactly. Outside those niches, octal is rare today — and the leading-zero literal (0755) is how generations of JavaScript developers have written numbers they didn't realise were being parsed in octal. Use the explicit 0o prefix when you mean it.

Read next

Frequently asked questions

Quick answers.

What number bases are supported?

Decimal (base 10), hexadecimal (base 16), octal (base 8) and binary (base 2).

Does it handle text?

Yes — convert a text string to its byte values in any base, or convert from bytes back to text (assumes UTF-8).

What's the largest number it handles?

Up to JavaScript's safe integer range (2⁵³). For bigger numbers, use BigInt-aware tools.

Is my input uploaded?

No — runs entirely in your browser.

Is the converter free?

Yes — fully free, no signup.

People also search for

Use with

What people reach for next.

Related tools

More in this room.

See all in Encoders & Crypto