Hex / Binary / Octal / Decimal Converter
Convert numbers between hexadecimal, binary, octal, and decimal. Shows the bit pattern grouped by nibble + the two’s-complement representation for negative values.
Result
How to use this calculator
- Type the number in any of the four supported bases. Prefixes 0x, 0b, 0o are auto-detected.
- Pick the base of the input if you are not using a prefix.
- Choose the bit width that matches the integer type you care about (uint8, int32, etc.).
- Read the four equivalent representations under the result. The binary is grouped per nibble for legibility.
- Negative numbers show both the signed decimal value and the unsigned two’s-complement bit pattern.
About this calculator
Programmers, embedded engineers, and CTF players all spend a surprising amount of time translating between number bases. This converter handles the four bases you actually see in code — binary, octal, decimal, hexadecimal — and also shows the two’s-complement representation at 8/16/32/64-bit widths so you can sanity-check negative integers, bitmask values, and sign-extension behavior. The 0x / 0b / 0o prefixes are auto-detected, so you can paste a value straight from source code without first stripping the prefix. Underscores, commas, and whitespace are tolerated as group separators (handy for long binary masks). Negative inputs return both the signed decimal value and the unsigned bit pattern at the chosen width.
How it works — the formula
value₁₀ = Σ (digitᵢ × baseⁱ)
two’s-complement(−n, N bits) = 2ᴺ − nA positional numeral system encodes a value as a weighted sum of digits where each weight is the base raised to that digit’s position. Two’s complement is the dominant binary signed-integer encoding because subtraction and overflow detection collapse to the same circuitry as unsigned addition.
Worked examples
- Inputs:
- value = FF, fromBase = 16
- Output:
- decimal 255, binary 0b 0000 0000 0000 0000 0000 0000 1111 1111
- Inputs:
- value = −1, fromBase = 10, width = 8
- Output:
- hex 0xFF, binary 0b 1111 1111 (two’s complement)
- Inputs:
- value = 1010_1100, fromBase = 2
- Output:
- hex 0xAC, decimal 172
Limitations
- Integer-only — no IEEE-754 float bit-pattern decoding.
- When the input exceeds the selected bit width, the hex/octal/binary columns wrap to the unsigned mask of that width; the decimal column keeps the exact value.
- Hex output is uppercased; lowercase output is not configurable.
BigInt-backed conversions: results are exact for any input size that fits in your browser’s memory. Bit-width selection only affects the masked unsigned representation, not the decimal output.
Frequently asked
How do I convert hexadecimal to decimal?+
What is two’s complement?+
Why does my hex value have leading zeros?+
Can I paste a value with underscores or spaces?+
What happens if the value is bigger than the selected bit width?+
Does this calculator handle floating-point bit patterns?+
Related calculators
More tools you might like
Hand-picked tools that pair well with this one — same audience, same intent.
Calculate what X% of a value is, find what percentage one number is of another, or compute the percentage change between two numbers.
Six-mode percentage tool — X% of Y, X is what % of Y, % change, % difference (symmetric), add %, and subtract %.
Convert a color between HEX, RGB, and HSL formats, with the parsed channel values and CSS-ready strings.
Convert a color between hex, RGB, HSL, HWB, and CMYK. Reports relative luminance and WCAG 2.2 contrast ratio against white and black.
Convert between satoshis and bitcoin (1 BTC = 100,000,000 sats) and optionally value either in US dollars at a given BTC price.
Look up the ASCII/Unicode codepoint for any character — or go the other way and turn a list of codepoints back into text. Shows decimal, hex (U+XXXX), octal, binary, HTML entity, JS escape, and URL-encoded forms for every code point.