Utility

Decimal to Hex

Convert decimal numbers to hexadecimal, with the padding and two's complement rules that matter in code.

Decimal to Hex

Convert Decimal numbers to Hexadecimal values.

Need this done properly for your business?

Radiatus delivers secure cloud, DevOps & compliance engineering.

Book a free consult

Repeated division by 16

Divide by 16, record the remainder, repeat with the quotient, then read the remainders backwards. 255 gives remainders 15 and 15, so 0xFF. Remainders 10 to 15 become A to F. For values under 256 it is faster to split into two digits directly: the high digit is the value divided by 16, the low digit is the remainder.

Padding is not cosmetic

A colour value, a MAC address or a fixed-width binary field needs a specific digit count, so 10 must be written 0A rather than A. Dropping leading zeros produces a string that parses to the right number and fails any format expecting alignment — a five-character CSS colour, or a MAC address that no longer matches its pattern.

Negative numbers use two's complement

Hex has no minus sign in machine representation. −1 in 32-bit two's complement is 0xFFFFFFFF and in 8-bit is 0xFF. The width has to be stated, because the same value produces entirely different hex at different widths — which is why a debugger showing 0xFFFFFFFE means −2 rather than 4.29 billion, depending on whether the type is signed.

Byte order changes the string

The 32-bit value 0x12345678 appears in memory as 78 56 34 12 on a little-endian machine and 12 34 56 78 on a big-endian one. A hex dump reads memory order, not numeric order, which is why values in a capture often look reversed.

Colours are three bytes, in order

#FF5733 is red 255, green 87, blue 51. Converting each channel separately and padding to two digits produces the string; converting the whole decimal number at once does not.

Frequently Asked Questions

Privacy & Security

Local conversion.

Data: None
Client-side-Side
Active
v1.0

About This Tool

This tool runs entirely in your browser. No data is sent to any server, ensuring complete privacy. Simply use the interface above to get started — no registration or login required.

Disclaimer: This tool is provided "as is" without warranty of any kind. Results are for educational and utility purposes.