PureDevTools

Decimal to Hex Converter

Convert decimal to hex — uppercase/lowercase, 0x prefix option, plus binary and octal

All processing happens in your browser. No data is sent to any server.

Decimal → Hex

Hexadecimal

HEXFF

Binary

BIN11111111

Octal

OCT377
Common hex values reference ▸
DecimalHex (uppercase)Hex (0x)Notes
0000x00Null
9090x09Tab
100A0x0ANewline
32200x20Space
1277F0x7FDEL
255FF0xFFMax byte
2561000x1002^8
10244000x4001 KiB
65535FFFF0xFFFFMax 16-bit
16777215FFFFFF0xFFFFFFMax 24-bit / white #FFFFFF

Every developer needs to convert decimal to hex regularly — CSS color values, memory addresses, error codes, byte constants in code. This converter gives you the hex output with formatting options (uppercase/lowercase, 0x prefix) plus binary and octal for free.

How Decimal to Hex Conversion Works

Divide by 16 repeatedly, collect remainders, read them in reverse. Remainders 10–15 become A–F.

Example: 255 → hex

255 ÷ 16 = 15 remainder 15  → F
15 ÷ 16  = 0  remainder 15  → F

Read bottom to top: FF
255 decimal = 0xFF

Example: 4096 → hex

4096 ÷ 16 = 256 remainder 0 → 0
256 ÷ 16  = 16  remainder 0 → 0
16 ÷ 16   = 1   remainder 0 → 0
1 ÷ 16    = 0   remainder 1 → 1

Result: 1000 → 0x1000

Formatting Options

Uppercase vs. Lowercase

Both are valid hexadecimal. Convention varies by context:

The 0x Prefix

0x signals “this is hexadecimal” to both humans and compilers. Required in C/C++/JavaScript literals:

int mask = 0xFF;         // required
int mask = FF;           // syntax error

Optional in HTML/CSS colors (#FF0000 uses # instead of 0x), SQL (x'FF' uses x-string notation), and documentation.

Decimal to Hex Lookup: Key Values

These appear constantly in systems work:

DecimalHexNotes
00x00Null, false, off
100x0ANewline (LF)
130x0DCarriage return (CR)
320x20Space character
48–570x30–0x39ASCII ‘0’–‘9’
65–900x41–0x5AASCII ‘A’–‘Z’
97–1220x61–0x7AASCII ‘a’–‘z’
1270x7FDEL / max ASCII
1280x80Min 8-bit extended / sign bit
2550xFFMax single byte
2560x100Carry out of 8 bits
10240x4001 KiB
655350xFFFFMax 16-bit unsigned
167772150xFFFFFFMax 24-bit / pure white in RGB

CSS Color Mathematics

Web colors are hex: #RRGGBB. Each channel is one byte (0–255 → 00–FF).

rgb(255, 140, 0) = #FF8C00  (dark orange)
  R: 255 = FF
  G: 140 = 8C   (140 ÷ 16 = 8 r 12 → 8C)
  B: 0   = 00

The opacity alpha channel adds a fourth byte in CSS: rgba(255, 0, 0, 0.5) = #FF000080 (50% opacity = 128 = 0x80).

Error Codes: Reading Windows HRESULT in Hex

Windows error codes are 32-bit hex values where the structure encodes severity, facility, and code:

When you see a Windows error as decimal (like 2147942487), converting to hex (0x80070057) makes it immediately recognizable.

Frequently Asked Questions

Why pad hex values with leading zeros? Padding aligns byte boundaries. 0x0F makes it clear there’s one byte; 0xF looks ambiguous. Security-sensitive code always pads to the expected size.

How many hex digits for N bits? Each hex digit covers 4 bits: ceil(bits / 4) digits. For 8 bits: 2 hex digits. For 32 bits: 8 hex digits. For 64 bits: 16 hex digits.

Is 0x prefix required in JavaScript? For number literals: yes. let n = 0xFF; But for string-based conversion: parseInt("FF", 16) doesn’t need it, while parseInt("0xFF", 16) also works.

Privacy

All conversions run entirely in your browser using JavaScript. No data is sent anywhere.

Related Tools

More Encoding & Crypto Tools