Decimal to Hexadecimal Converter
Convert a decimal number to its hexadecimal and binary representation.
Supports 2–20-bit signed representations with two's complement for negative values.
Updated August 12, 2026
Introduction / overview
Decimal to Hexadecimal Converter turns any whole decimal number into its hexadecimal equivalent — and, because every four binary digits collapse into a single hex digit, it also shows the binary value grouped into nibbles so reads as instead of a wall of digits.
Negative values are handled with two’s complement, and the conversion is an exact integer operation — nothing is rounded. By default the tool works in a 16-bit representation, and you can switch to any width from 2 to 20 bits.
It is the tool to reach for when you are reading a hex value from code, an address, a color, a register dump, or a network trace, and you need to know what decimal value sits behind it. Programmers, students, and anyone learning how computers store integers all end up converting decimal to hex sooner or later.
How to use / quick start
Enter a whole decimal number
Type the value into the Decimal field. The input domain shown above the field (for example −32,768 to 32,767 at the default 16 bits) tells you what fits in the current representation. Whole numbers only — decimals and fractions are not converted.
Read the Binary and Hexadecimal results
The Binary row shows the value padded to the selected bit width and grouped in blocks of four; the Hexadecimal row shows the uppercase hex form you can copy straight into code or documentation.
Change the bit width when you need to
Turn on Change the binary representation to pick a preset — 4, 8, 12, or 16 bits — or choose Other and type any width from 2 to 20. A wider representation accepts a wider range of values.
Example — convert 4987 to hex
Type in the Decimal field. Repeating the “divide by 16, keep the remainder” step from the bottom up:
Reading the remainders from last to first gives . The tool shows Binary: 0001 0011 0111 1011 and Hexadecimal: 137B at the default 16-bit width.
Calculation method
For a non-negative value, the binary representation is just the usual place-value encoding padded with leading zeros to the chosen width. For a negative value, the tool uses two’s complement: it adds to the number, then encodes that result in bits.
The hexadecimal result is produced from the same encoded value: starting from the right, the bits are split into groups of four (nibbles), and each group maps to a single hex digit.
Worked example — negative value
For at 16 bits, the encoded value is , which is in binary:
Every negative value therefore starts with a run of bits — that leading nibble is the two’s-complement “sign marker”, not a large number.
Variables
- — the decimal input value
- — the encoded value held in bits
- — the bit width (2–20)
- — the -th hex digit (0–9, A–F)
- — the bit at position (0 or 1)
Conversion is one-directional: the Binary and Hexadecimal rows are read-only results derived from the Decimal input. If you already have a hexadecimal value and want its decimal form, use the binary to hexadecimal converter, which converts both ways.
Frequently asked questions
Why is −1 shown as FFFF at 16 bits?
Because two’s complement encodes as , which is in binary — and in hex. The leading run of s is the sign marker; the same pattern would mean only if interpreted as unsigned.
Why do I see “Your data input exceeds the allowed limits”?
The number is too large (or too negative) for the current bit width. For example, at 8 bits the largest value is , so is rejected. Turn on Change the binary representation and pick a wider width — the input domain note updates immediately to show the new range.
Why does the binary result start with so many zeros?
The value is padded to fill the selected bit width, then grouped into nibbles. At 16 bits, becomes . The leading zeros are part of the fixed-width representation and do not change the value.
Can I convert hexadecimal back to decimal here?
Not on this page — the output is read-only and the conversion is one-directional. To go the other way, or to convert between binary and hexadecimal directly, use the binary to hexadecimal converter.
Limitations
This calculator accepts whole decimal numbers only — a decimal point or fraction produces an “Enter a whole number.” message and nothing is converted. The bit width is limited to 2–20 bits, with 16 bits as the default. Negative values are interpreted as signed two’s complement, so the same input produces different binary and hex output at different widths, and numbers outside the current width’s range are not converted until you widen the representation. There is no hex-to-decimal direction on this page.
Related Calculators
Scale Calculator
Calculate scale factors and convert scaled or real dimensions for length, area, and volume.
Text to Unicode
Convert text to Unicode decimal HTML entities (e.g., A) and convert them back to text. Runs locally in your browser with one-click copy.
Integer Base Converter
Convert an integer between bases 2–64 (binary, octal, decimal, hexadecimal, base64, and custom). Runs locally in your browser.
IPv4 address converter
Convert an IPv4 address into decimal, binary, hexadecimal, and IPv4-mapped IPv6 representations. Runs locally in your browser with one-click copy.
Roman Numeral Converter
Convert an Arabic number up to 3,999,999 into Roman numerals or read a Roman numeral back into a number. Both directions run in your browser.
Fraction to Percent Calculator
Convert fractions to percentages and vice versa instantly