All Tools

Decimal to Hex Converter: Exact, Any Length

Convert decimal to hexadecimal exactly, in upper or lower case, for numbers of any size, with binary and octal alongside. Runs in your browser. Nothing is uploaded.

Binary digits
Two's complement width

About the Decimal to Hex Converter

This page opens the Number Base Converter with decimal as the input and hexadecimal highlighted at the top of the results. Type any whole number and you get its exact hexadecimal form, in lower or upper case, with binary, octal, BCD, Gray code and two's complement alongside. Each result has a Copy button. It works for numbers of any size, and it runs in your browser: nothing is uploaded.

How to use it

Steps

  1. Type or paste the decimal number. Spaces and underscores between digits are ignored, and a leading minus sign is kept.
  2. Read the hexadecimal result at the top. Turn on Upper case if you need FF rather than ff.
  3. Add a 0x prefix or a # yourself when you paste the result into code or a stylesheet; the converter gives the bare digits so they fit any notation.
  4. For a negative number that should be stored as a fixed-width integer, read the Two's complement row with a width of 8, 16, 32 or 64 bits. Each group of four bits is one hex digit.

How decimal becomes hex

Repeated division by 16

Divide the number by 16 and write down the remainder as a hex digit, using a to f for 10 to 15. Then divide the quotient again until it is 0, and read the remainders from last to first. For 755: 755 ÷ 16 = 47 remainder 3, 47 ÷ 16 = 2 r 15 (f), 2 ÷ 16 = 0 r 2. Reading upwards gives 2f3.

Exact for any size

The page uses arbitrary-precision integers rather than floating point, so values past 2 to the power of 53, the limit for ordinary JavaScript and spreadsheet numbers, still convert exactly. The 39-digit number 340,282,366,920,938,463,463,374,607,431,768,211,455 becomes thirty-two f digits with no rounding. Inputs of up to 10,000 digits are accepted.

Hex and bytes

Two hex digits make one byte. The number 4,294,967,295 is ffffffff, four bytes with every bit set. Colours in CSS use one byte per channel, so the decimal channel values 255, 136 and 0 become ff, 88 and 00, or #ff8800.

Common values

  • 10 is a, 15 is f, 16 is 10 and 255 is ff.
  • 4,096 is 1000 and 65,535 is ffff.
  • 2,147,483,647 is 7fffffff, the largest signed 32-bit integer.

Privacy

The conversion is done by code on this page in your browser. Nothing is sent to a server, and nothing is kept after you close the tab.

Related tools

To read hex back as decimal, use Hex to Decimal. For binary output, use Decimal to Binary. For arithmetic on hex values, open the Binary Calculator. To turn text into hex byte codes, use Text to Hex.

Open-source credits

  • The converter is written for this site and uses no third-party library. Arithmetic uses the browser's built-in BigInt, specified in ECMA-262, the ECMAScript language specification.
  • Two's complement follows the signed integer representation required by ISO/IEC 9899:2024 (C23).

Other related tools