Utility

Decimal to Hex

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

Last reviewed by the Radiatus Cloud team

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.

Related tools

  • User Agent Parser — Parse a User-Agent string into browser, engine, operating system and device. Explains why UA strings are unreliable and what to use instead.
  • QR Code Generator — Generate QR codes for URLs, text, Wi-Fi and contact details. Adjustable error correction and size, produced entirely in your browser.
  • Credit Card Validator — Validate a card number with the Luhn algorithm and identify the issuing network from its prefix. Runs locally, nothing is transmitted.
  • Text Case Converter — Convert text between camelCase, PascalCase, snake_case, kebab-case, CONSTANT_CASE, Title Case and sentence case. Runs entirely in your browser.

Frequently Asked Questions

How do I convert decimal to hex manually?

Divide by 16 repeatedly, recording remainders, then read them backwards. Remainders 10 to 15 become A to F, so 255 gives FF.

Why does padding matter?

Because fixed-width formats need a specific digit count. Writing A instead of 0A produces a five-character CSS colour or a MAC address that no longer matches its pattern.

How are negative numbers written in hex?

In two's complement, with the width stated. −1 is 0xFF at 8 bits and 0xFFFFFFFF at 32, so the same value looks entirely different at different widths.

Why do hex values look reversed in a memory dump?

Byte order. On a little-endian machine 0x12345678 is stored as 78 56 34 12, and a dump shows memory order rather than numeric order.

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.