← All tools

Stays in your browser

Number Base Converter — Bin / Oct / Dec / Hex

Free number base converter between binary, octal, decimal, and hexadecimal.

Binary
11111111
Octal
377
Decimal
255
Hex
FF

Converting between bases without off-by-one mistakes

A number is the same value written differently, and converting does not change it. That is why a leading zero is dangerous: where a leading zero signals octal, the value is not the decimal number it appears to be, and a converter that guesses wrong changes the meaning rather than the notation.

Prefixes are the machine-readable hint. 0x marks hexadecimal and 0b marks binary in most languages, while a bare string of digits is ambiguous beyond the characters the two bases share. State the base explicitly whenever a value crosses a boundary between systems.

Watch the width. A 32-bit value is conventionally eight hex digits, so a converter that drops leading zeros produces a short form where a protocol expects a fixed-width field. That matters for hashes, colours and binary formats, and not at all for display.

FAQ

Is 0x supported?
In hex mode you may include or omit the 0x prefix.
Negative numbers?
This tool focuses on non-negative integers.
Is data uploaded?
No.
Why does a number with a leading zero convert to something else?
A leading zero signals an octal literal in several languages, so 010 is eight rather than ten. When the intent is decimal, strip the leading zeros or state the base explicitly, and never rely on a converter to infer it from the shape of the string.
How do I convert an RGB colour to hex?
Each channel is a number from 0 to 255, which is exactly two hex digits. Convert the three channels separately and concatenate them, padding each to two digits, so a channel with value 10 becomes 0A rather than A.
What is the largest number I can convert here?
The practical ceiling is the precision of a JavaScript number, which is exact only up to 2 to the 53rd power minus one. Larger values lose precision silently and the trailing digits change, so convert big integers as strings rather than as numbers.

Related tools