Skip to main content
Data / Number / Computer Science Tools

Decimal to Hex Converter

Convert a decimal number to its exact hexadecimal value, handling arbitrarily large integers correctly.

Enter a decimal number below - this tool converts it to hexadecimal exactly.

Supports integers up to 2^53-1 (JavaScript's safe integer limit) - for larger values, precision beyond this range cannot be guaranteed.

For the reverse direction, see the Hex to Decimal Converter.

How Decimal-to-Hex Conversion Works

The number is repeatedly divided by 16, with each remainder (0-15, represented as 0-9 and A-F) recorded - reading the remainders from last to first gives the hex representation.

How to Use It

  1. Enter a non-negative integer.
  2. The hexadecimal equivalent appears instantly.

Limitations

This handles arbitrarily large integers accurately using BigInt, avoiding the precision loss standard JavaScript number handling would introduce for very large values.

Worked Example

Convert 3054 to hexadecimal:

  • 3054 ÷ 16 = 190, remainder 14 (E)
  • 190 ÷ 16 = 11, remainder 14 (E)
  • 11 ÷ 16 = 0, remainder 11 (B)

Reading the remainders from last to first gives BEE, often written 0xBEE.

Hex Digits

Decimal101112131415
HexABCDEF

Where Hex Is Used

  • Colours: in #FF8800, each pair is a channel from 0 to 255 - FF = 255, 88 = 136, 00 = 0.
  • Memory addresses and byte values in debuggers and hex editors.
  • Unicode code points such as U+20B9 (₹).
  • Hashes and IDs: MD5, SHA-256 and UUIDs are written in hex.

Each hex digit is exactly four bits, which is why hex is a compact way to write binary: F = 1111, FF = one byte.

Go back with Hex to Decimal, or convert between any bases with the Number Base Converter.

Frequently Asked Questions

Divide by 16 repeatedly and write the remainders (10-15 as A-F), then read them from last to first. 255 = FF.

Convert each of the red, green and blue values (0-255) to two hex digits and join them: rgb(255, 87, 51) = #FF5733.

Integers up to 2^53 - 1 (9,007,199,254,740,991), JavaScript's safe integer limit. Larger values are rejected rather than converted with lost precision.
Share this tool: