Skip to content
mathbehind

Number Base Converter

Convert a number between binary, octal, decimal, and hexadecimal, instantly, in either direction.

Your numbers

Digits only, matching the base selected below (e.g. only 0-1 for binary).

Decimal (base 10)

255

Binary (base 2)
11111111
Octal (base 8)
377
Hexadecimal (base 16)
FF

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.

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.