dh

Decimal to HEX

βœ“ Free & no signup πŸ”’ Runs 100% in your browser Updated 2026-11-25 Binary Converter Tools

Color values, register constants, and status codes live in hexadecimal, and writing them by hand means repeated division by 16 and remembering that ten through fifteen are letters. This tool does that arithmetic instantly: type a decimal number and its hex form appears live, in uppercase, exactly the notation used in editors, protocol documents, and CSS. It runs entirely in your browser with no uploads and no signup, so constants from internal codebases stay on your machine.

The essentials up front: 255 becomes FF, the all-ones byte, and 256 becomes 100, one digit wider. The tool treats your input as a single number, not text, which is a distinction worth pausing on. The number 255 is one value that fits in one byte; the text 255 is three characters with three separate codes. If you need per-character conversion of a string, use the text-family tools; this page is for quantities, and it handles integers of effectively unlimited size using arbitrary-precision arithmetic.

Output is uppercase by convention, matching the dominant style in technical documentation and debugger displays, so 4660 prints as 1234, 255 prints as FF, and 3735928559 prints as DEADBEEF. Lowercase would be numerically identical; case is presentation. If your destination system, such as a URL fragment or a case-sensitive config parser, requires lowercase, note it when copying, though the value itself is unaffected.

What Is Hexadecimal and Why Do Programmers Prefer It?

Hexadecimal is base 16, using the sixteen digits 0 through 9 followed by A through F for ten through fifteen. Its advantage over decimal is bit alignment: sixteen is 2 to the 4th power, so one hex digit represents exactly four bits and two hex digits represent one byte. A 32-bit register is always eight hex digits, a byte is always two, and there is never a leftover. Decimal, with its base of 10, straddles bit boundaries, which is why constants defined in decimal are hard to verify bit-by-bit while hex constants read like open registers.

Writing a number in hex therefore means finding how many times each power of 16 fits. The weights run 1, 16, 256, 4096, 65536, and upward. The standard algorithm is repeated division by 16: divide, record the remainder as the next digit from the right, continue with the quotient until it reaches zero. Remainders ten through fifteen are written as letters A through F, and the first remainder produced is the rightmost digit, the same bottom-up extraction as decimal-to-binary but with a larger base, so the digit count shrinks four times faster.

How to Use This Tool (Step by Step)

  1. Type a non-negative integer into the input box. Commas and spaces in long numbers are tolerated and stripped.
  2. Read the uppercase hex result live with every keystroke; there is no submit step.
  3. Invalid input, such as a minus sign or a decimal point, produces a specific error message rather than a wrong answer.
  4. Copy the result with one click, or verify with a round trip through the hex-to-decimal tool.

Worked Examples with Full Arithmetic

Here is 2026 converted by repeated division by 16: 2026 divided by 16 is 126 remainder 10, so the rightmost digit is A. Then 126 divided by 16 is 7 remainder 14, giving digit E. Finally 7 divided by 16 is 0 remainder 7. Reading the remainders bottom-up gives 7EA. Check it in reverse: 7 times 256 is 1792, plus 14 times 16 is 224, plus 10, totaling 2026. The same method on other familiar values produces this reference table:

DecimalHexWhy it matters
15FOne nibble, four bits all set
1610First two-digit hex number
255FFFull byte; max color channel
256100One byte of zeros after the 1
40961000Page-size territory
65535FFFFMax 16-bit value; port range ceiling
16777215FFFFFFWhite in RGB, 24-bit color maximum
4294967295FFFFFFFFMax unsigned 32-bit value

Two rows deserve emphasis. The 255 and 256 pair shows the cliff: FF is eight set bits, and 100 is a carry into a new digit, which is why limits like 255 and memory boundaries like 256 recur everywhere. And the color row shows a practical identity worth memorizing: decimal 16777215 is exactly hex FFFFFF, pure white on the web, because a 24-bit color is three bytes of eight bits each.

Common Use Cases

  • CSS and design work: converting decimal channel values to hex pairs builds color codes directly; the triple 255, 99, 71 becomes FF, 63, 47 and then the code FF6347, the tomato shade.
  • Register and flag constants: hardware documentation lists bit patterns, and code reviews read better with hex constants; converting candidate decimal values to hex exposes which bits are set at a glance.
  • Error code lookup: logs often print decimal while official documentation lists hex, and translating between them is daily troubleshooting work for Windows and game-engine errors.
  • Memory sizing: offsets and allocation sizes in debugger output are hex; converting decimal sizes to hex reveals alignment properties that decimal hides, like whether a size is a clean multiple of 16.
  • Teaching base conversion: repeated division by 16 is the natural next exercise after binary, and live verification beats an answer key.

How It Works Internally and Why Large Values Stay Exact

The conversion walks the repeated-division algorithm using arbitrary-precision integers, JavaScript's BigInt, so values with dozens of digits convert exactly. This matters at real-world scales: the maximum unsigned 64-bit value is 18446744073709551615 in decimal, and ordinary floating-point arithmetic cannot represent that number exactly, silently corrupting low digits, but BigInt division extracts every hex digit correctly, producing FFFFFFFFFFFFFFFF. A magnitude sanity check helps catch transcription errors: each hex digit carries about 1.2 decimal digits' worth of range, since 16 is roughly 10 raised to the 1.2, so a 10-digit decimal value should produce about 8 to 9 hex digits, and a wildly shorter result means a digit was lost.

One more property follows from the byte alignment: a decimal value divisible by 256 always ends in 00 in hex, and one divisible by 16 always ends in 0. Those two quick tests turn hex output into a checksum for alignment questions, which is exactly the kind of check memory-layout work demands.

Decimal-to-Hex Versus Decimal-to-Binary

Both tools run the same repeated-division structure, differing only in the divisor, but they answer different questions. Hex answers "which bits are set" in compact, transcribable form: eight digits for a 32-bit word instead of thirty-two. Binary answers it exhaustively, at the cost of readability. The professional habit is to think in hex and expand to binary only when individual flags matter, and the two tools here support that habit directly: convert to hex for notation, then use hex-to-binary when you need to inspect a specific bit. Converting the same value both ways and checking consistency, 255 as FF as 11111111, cements the relationship that all bases are names for one quantity.

Tips and Best Practices

  • Validate with anchors: 255 must give FF, 65535 must give FFFF; any deviation means the input was typed wrong.
  • Pad to your context's width: an 8-bit constant shown as F should be written 0F when it lives in a byte pair, so leading zeros in documentation stay intentional.
  • Use the divisibility tests: endings of 0 and 00 in hex prove multiples of 16 and 256, which is a fast alignment check for sizes and offsets.
  • Round-trip constants before committing them: paste the hex into hex-to-decimal and confirm the original number returns exactly.
  • Remember scope: this tool converts non-negative integers; negative values need a signed representation like two's complement, which depends on a chosen bit width and is a separate decision.

Frequently Asked Questions

How do I convert decimal to hex by hand?
Divide repeatedly by 16 and write the remainders from right to left, using A through F for remainders ten through fifteen. For 2026: 2026 divided by 16 gives 126 remainder 10, so digit A; 126 divided by 16 gives 7 remainder 14, so digit E; and 7 gives final digit 7. Read bottom-up for 7EA. Verify by weighting: 7 times 256 plus 14 times 16 plus 10 equals 2026. The first remainder is always the rightmost digit, exactly as in decimal-to-binary but dividing by 16.
What is 255 in hex and why is it FF?
255 is FF. Each F is fifteen, and 15 times 16 plus 15 equals 255, making FF the largest two-digit hex value and the all-ones byte. Its successor, 256, is 100 in hex, one digit wider, because 255 fills every bit of a byte and 256 requires a carry. This cliff explains why 255 appears as the maximum everywhere: color channels from 0 to 255, a single byte's range, and netmask octets. In CSS, the white color FFFFFF is three FF bytes, decimal 16777215.
How do I convert a decimal RGB color to a hex code?
Convert each of the three channel values to a two-digit hex pair and join them. For the decimal triple 255, 99, 71: 255 is FF, 99 is 6 times 16 plus 3 which is 63, and 71 is 4 times 16 plus 7 which is 47, giving the code FF6347, the tomato shade. Channels below 16 need a leading zero, so a red value of 5 becomes 05. Prefix the three pairs with a hash sign for CSS. Each pair must stay two digits so the code is always exactly six hex digits.
Why does hex output use uppercase letters?
Uppercase is the dominant convention in technical documentation, debugger displays, and style guides, so this tool prints FF rather than ff. The case carries no numerical meaning: FF, ff, and Ff all equal 255, and every converter treats them identically. Case only matters when a string is compared as text, such as in case-sensitive configuration parsers or URL fragments, where mixing styles can break matching. When copying into such contexts, match the destination's convention, though the underlying value is unaffected either way.
Can this tool convert very large decimal numbers to hex?
Yes. The conversion uses arbitrary-precision integer arithmetic, JavaScript's BigInt, so numbers with dozens of decimal digits convert exactly, including values beyond what floating-point math can represent without corruption. The maximum unsigned 64-bit value, 18446744073709551615, correctly becomes FFFFFFFFFFFFFFFF, sixteen F digits. Ordinary calculators and naive code lose low-order digits at such scales, silently producing wrong constants. The practical limits are browser memory and display, not the algorithm, and copying large outputs rather than retyping them avoids transcription errors.
Is decimal-to-hex the same as converting text characters?
No, and the distinction matters. This tool treats the input as one number: 255 becomes FF, a single value that fits in one byte. A text converter treats each character separately: the string 255 becomes three character codes, 50, 53, and 53, because digits are symbols there, not a quantity. Use this tool for register values, color channels, and numeric constants, and use the text-to-ascii or text-to-binary tools for encoding strings like IDs or messages. Feeding a number to the wrong tool produces either unreadable symbols or a misleading byte pattern.

Related Tools