How to use the Decimal to Hex
Convert decimal to hex in two steps:
1
Enter the decimal number
Type or paste any positive integer. The result updates instantly as you type.
2
Copy the hex result
The hex output shows both the full value (0xFF) and byte-grouped display. Click Copy to copy the raw hex without the 0x prefix.
When to use this tool
Use to convert decimal values to hex for color codes, memory addresses, and protocols:
- →Converting decimal RGB color values (0–255) to hex for writing CSS color codes and HTML hex colors
- →Generating hex memory addresses or offsets from decimal values when writing assembly or low-level C code
- →Creating hex bitmask values from decimal flag values for use in C bitfield operations or hardware register programming
- →Converting decimal error codes to hex for matching against Windows, Linux, or macOS hex error code documentation
- →Encoding decimal integers as hex for embedding in binary file formats, network protocols, or configuration files
- →Converting decimal character codes to hex to produce escape sequences like \x41 for 'A' in string literals
Frequently asked questions
Q:How does decimal to hex conversion work?
The algorithm repeatedly divides the decimal number by 16, collecting the remainders as hex digits from 0–9 and A–F (for remainders 10–15). Reading the remainders in reverse order gives the hex representation. Example: 255 ÷ 16 = 15 R 15 (F); 15 ÷ 16 = 0 R 15 (F) — reading upward: FF. The tool uses JavaScript BigInt internally, allowing exact conversion of arbitrarily large decimal numbers.
Q:Why does the output show both 0xFF and byte groups like 'DE AD'?
The 0x prefix is the standard programming notation indicating a hexadecimal value — used in C, Python, JavaScript, and most languages. The byte-grouped display (pairs of hex digits separated by spaces) mirrors the format used in memory editors, hex dumps, and network packet captures, where each byte is shown as two hex digits. Both representations contain the same value — the format choice depends on your context.
Q:What decimal number equals 0xFF?
0xFF = 255. This is one of the most important hex values to memorise: it represents 11111111 in binary — all 8 bits of a byte set to 1. Key reference values: 0x0F = 15, 0x10 = 16, 0xFF = 255, 0x100 = 256, 0xFFFF = 65535, 0x10000 = 65536, 0xFFFFFF = 16777215 (max 24-bit), 0xFFFFFFFF = 4294967295 (max 32-bit unsigned).
Q:How do I convert a decimal number to a CSS hex color?
CSS hex colors are formed by concatenating the hex representations of red, green, and blue channels (each 0–255). Convert each channel separately: for RGB(255, 87, 51), convert 255 → FF, 87 → 57, 51 → 33, producing #FF5733. Each channel's hex must be exactly 2 digits — pad with a leading zero if needed (e.g. decimal 5 → '05' not '5'). This tool shows the hex with byte grouping, making it easy to read the 2-digit pairs for each channel.
Q:What are the most important decimal-to-hex values to know?
Key values every developer should recognise: 10 = 0xA, 15 = 0xF, 16 = 0x10, 32 = 0x20, 64 = 0x40, 128 = 0x80, 255 = 0xFF, 256 = 0x100, 512 = 0x200, 1024 = 0x400, 4096 = 0x1000, 65535 = 0xFFFF, 65536 = 0x10000. Powers of 2 in hex are always a 1 followed by zeros: 2⁸ = 0x100, 2¹⁶ = 0x10000. Powers of 16 are trivially 0x10, 0x100, 0x1000.
Q:Does the tool output uppercase or lowercase hex?
The tool outputs uppercase hex (A–F rather than a–f) by default, matching the most common convention in programming documentation, memory editors, and hardware datasheets. Uppercase hex is also used by the 0x prefix convention in C, the printf %X format, and most assembly languages. If you need lowercase hex (e.g. for CSS color codes like #ff5733 or JSON), convert the copied value to lowercase manually — both are equally valid hex representations.