Audited ·Last updated 31 Jul 2026·5 citations·Tier 1·0 uses

Binary Converter — Binary, Decimal, Octal & Hex

Convert non-negative integers among binary, octal, decimal and hexadecimal exactly, including values larger than JavaScript's safe integer range.

Binary Converter

Input notation
Up to 128 digits. Underscores and leading zeroes are accepted. Fractions, signs and signed machine-word interpretations are outside this calculator.
Binary (base 2)
11010110
The integer written with 0 and 1, without an added prefix or insignificant leading zeroes.
Octal (base 8)
326
Decimal (base 10)
214
Hexadecimal (base 16)
D6
Significant binary digits
8
Significant hexadecimal digits
2

Background.

Binary, decimal, octal and hexadecimal are not four different values. They are four alphabets for writing the same non-negative integer. Decimal uses ten digit symbols and each place is ten times the place to its right. Binary uses only 0 and 1 and each place is twice the next. Octal uses eight symbols, while hexadecimal uses sixteen: 0 through 9 followed by A through F for values ten through fifteen.

This converter keeps that distinction visible. Enter an integer in any of the four notations and it prints all four representations at once. It does not pass the value through JavaScript's ordinary number type, so a long identifier is not silently rounded at 9,007,199,254,740,991. The arithmetic is performed digit by digit with a high-precision Decimal.js context and the full decimal answer stays text all the way to the result.

Binary and hexadecimal fit together especially neatly. NIST explains that four binary digits correspond to one hexadecimal digit, and RFC 4648 publishes the complete mapping. Binary 1010 is hexadecimal A, 1111 is F, and an eight-bit byte can therefore be displayed as exactly two hexadecimal digits when padding matters. Octal groups binary digits by threes instead. Those grouping shortcuts are a way to check the result, but the calculator itself evaluates the integer positionally and therefore handles an input whose digit count is not a tidy multiple of three or four.

Prefixes are accepted for convenience: 0b for binary, 0o for octal, 0d for decimal and 0x for hexadecimal. Underscores and leading zeroes may be used for readability and are removed before conversion. The result omits prefixes and insignificant leading zeroes so the four lines are easy to copy. Zero remains 0 rather than becoming an empty string.

The width figures describe the shortest representation, not a storage allocation. Decimal 255 needs eight significant binary digits and two hexadecimal digits, but a file format could place that value in a sixteen-bit or thirty-two-bit field by adding leading zeroes. The extra positions do not change the integer. Likewise, a hexadecimal digit is a convenient display for four bits, but a value containing an odd count of hex digits is not malformed. Its leftmost group simply uses fewer than four significant bits. Keeping numeric value separate from field width prevents a common conversion error: treating display padding as new information.

The input limit is also about exactness rather than machine architecture. You may enter values much larger than a 64-bit processor register, and the converter will preserve every digit. It uses a local precision context large enough for the published 128-character envelope, then constructs each result by exact integer division. There is no logarithm used to guess the answer's length and no floating-point shortcut used to parse the source string. That is why the full 2^128 − 1 value and similarly large decimal identifiers round-trip without losing their final digits.

Scope matters with bit strings. The digits 11111111 can mean the unsigned integer 255, the signed eight-bit integer −1, a byte in a text encoding, or part of a floating-point value. Nothing in the digits alone chooses among those meanings. This page treats every input as a non-negative mathematical integer. It deliberately does not guess a word width, two's-complement sign, character encoding or byte order. Use it when you want the value of an integer in another base; use a domain-specific decoder when the surrounding bits carry structure.

What is binary converter?

A positional numeral system assigns a base to a string of digits. Reading from the right, the places have weights base to the powers 0, 1, 2 and onward. Binary 1101 therefore means 1×2³ + 1×2² + 0×2¹ + 1×2⁰ = 13. Decimal 13 expresses the same value as 1×10 + 3, octal 15 expresses it as 1×8 + 5, and hexadecimal D expresses it with the single digit whose value is thirteen. Conversion can be done without a floating-point approximation: consume the source digits from left to right, multiplying the accumulated integer by the source base and adding the next digit. To write the result in another base, repeatedly divide by that base and read the remainders in reverse order. Because hexadecimal has sixteen symbols and sixteen equals 2⁴, every hexadecimal digit maps to four binary positions. Because eight equals 2³, every octal digit maps to three. Padding is contextual rather than numeric: hexadecimal 1, 01 and 0001 are the same integer even though a protocol may require a fixed-width field.

How to use this calculator.

  1. Choose the notation already used by your input. Do not choose the notation you want as the output; all four outputs are always shown.
  2. Enter a non-negative integer. Conventional 0b, 0o, 0d or 0x prefixes are optional when they agree with the selected mode.
  3. Use underscores if they make a long value easier to read. They are separators only and do not affect the value.
  4. Read the exact string beside the target base. The converter removes insignificant leading zeroes and uses uppercase A–F.
  5. If the bit string is supposed to be signed, a character, a packet field or a floating-point encoding, establish its width and encoding before interpreting it; this page intentionally treats it only as an unsigned integer.

The formula.

value = (((d₀ × b + d₁) × b + d₂) …); output digits = repeated value mod t

The positional rule can be written as a sum, but the left-to-right recurrence is safer to implement. Start at zero. For every source digit, multiply the accumulated value by the source base and add the digit. Binary 11010110 becomes 1, then 3, 6, 13, 26, 53, 107 and finally 214. Every operation is integer arithmetic.

To produce a target representation, divide the value by the target base. The remainder is the rightmost digit; divide the quotient again and continue until it reaches zero. For 214 in hexadecimal, 214 modulo 16 is 6 and the quotient is 13. Thirteen maps to D, so reversing the remainders gives D6. In octal, the remainders are 6, 2 and 3, giving 326. Zero is handled explicitly because repeated division would otherwise produce no digits.

Hex grouping is an independent cross-check. RFC 4648's base-16 alphabet assigns A through F to ten through fifteen, and each character represents four bits. Pad 11010110 on the left to groups of four: 1101 is D and 0110 is 6. Octal groups from the right in threes: 011, 010, 110 becomes 3, 2, 6. Padding added only to form groups is discarded in the canonical result.

The accepted input length is capped at 128 characters and evaluated with 220 decimal digits of working precision. This makes every accepted value exact, including a 128-digit hexadecimal integer, while preventing accidental submission of an enormous string that would add no practical value. The decimal output remains a string; converting it to a JavaScript Number would destroy exactness for many perfectly valid inputs.

A worked example.

Example

Convert binary 11010110. Positional evaluation gives 1×128 + 1×64 + 0×32 + 1×16 + 0×8 + 1×4 + 1×2 + 0 = 214. For hexadecimal, split the binary digits into groups of four from the right: 1101 and 0110. RFC 4648's alphabet maps 1101 to digit D and 0110 to digit 6, so the hexadecimal representation is D6. For octal, pad on the left and group by threes: 011 010 110 maps to 3, 2 and 6, so the result is 326. The exact outputs are binary 11010110, octal 326, decimal 214 and hexadecimal D6. The unpadded value uses eight binary digits and two hexadecimal digits.

value11010110
input Basebinary

Frequently asked questions.

How do I convert binary to decimal?
Multiply each bit by its power-of-two place value and add the results. From the right the weights are 1, 2, 4, 8, 16 and so on. Binary 10110 is 16 + 4 + 2 = 22. The calculator performs the equivalent left-to-right recurrence, which avoids building a separate power for every position.
How do I convert binary to hexadecimal?
Group the binary digits into sets of four from the right, padding only the leftmost group with zeroes if needed. Map 0000 through 1001 to 0 through 9 and 1010 through 1111 to A through F. For example, 10101111 groups as 1010 1111, which is AF.
Why does hexadecimal use letters?
Base 16 needs sixteen single-digit symbols. Decimal already supplies ten, so A, B, C, D, E and F conventionally stand for values ten through fifteen. RFC 4648 standardizes that alphabet for base-16 encoding and treats letter case as interchangeable; this page prints uppercase.
Are 0xFF and FF the same value?
Yes when both are identified as hexadecimal. The 0x prefix is a notation marker, not a digit and not part of the value. RFC 7373 uses 0x for base 16 and 0b for base 2. This calculator accepts the matching prefix and removes it before evaluating the digits.
Do leading zeroes change a binary number?
Not as a mathematical integer. Binary 101, 0101 and 00000101 all equal decimal 5. Leading zeroes can matter in a fixed-width protocol, memory word or byte display, but that width is metadata outside the integer itself. The calculator returns the shortest canonical representation.
Can I convert a negative binary number here?
No. A minus sign denotes an ordinary negative integer, while a leading one in a machine word may denote a negative two's-complement value only after a word width is specified. Because the same bit string changes meaning at 8, 16, 32 or 64 bits, this page refuses to guess and accepts non-negative integers only.
Why is my long decimal value returned as text?
JavaScript's ordinary Number type cannot represent every integer above 9,007,199,254,740,991. Returning a long integer as a number could silently change its final digits. This calculator carries the value in Decimal.js and keeps base representations as strings so the copied result remains exact.
Does this convert text or files to binary?
No. Turning text or a file into binary first requires an encoding such as UTF-8 and then a decision about how bytes are displayed. This page converts the radix notation of one unsigned integer. It does not infer character encodings, byte order, signedness, colors or floating-point layouts.

In this category

Embed

Quanta Pro

Paid features are coming later.

  • All 977 calculators remain free
  • No billing is enabled
Coming soon