Decimal to Hex Converter
Convert decimal to hexadecimal instantly — exact at any size — with 0x prefix, byte padding and two's complement for negatives.
About this number
What It Does
This converter writes a decimal number in hexadecimal. It is exact for numbers of any size, including 64-bit IDs and values beyond what JavaScript can hold, and it tells you how many bytes the result occupies. Options add the 0x prefix, pad to an even number of digits, and switch between upper and lower case.
When to Use It
- You need a decimal constant as a hex literal in code.
- You are converting an RGB channel value (0–255) to its two-digit hex form for a colour.
- You are matching a decimal error or status code against hex documentation, such as Windows HRESULTs.
- You need a large database ID or Snowflake ID in hex without losing precision.
Worked Examples
255
FF — one byte, all bits set. Also the maximum value of one colour channel.
3735928559
DEADBEEF. Four bytes, so it fits a 32-bit unsigned integer.
9007199254740993
Larger than 2^53 − 1. Exact here (20000000000001), but JavaScript's Number would round it.
Features
How to Use
1. Type or paste a decimal number — or a list, one per line. 2. The hex value appears alongside, line for line. 3. Use the options to group digits or add a prefix, and the swap button to convert the other way.
Common Mistakes
- Converting a number through a JavaScript Number. Above 9,007,199,254,740,991 it silently rounds, so the last digits come out wrong. This tool uses BigInt and stays exact at any size.
- Forgetting that the same digits mean different values in different bases. 10 is ten in decimal, two in binary, eight in octal and sixteen in hex — always label which base a value is in.
- Treating a minus sign as how a computer stores a negative number. Hardware uses two's complement, so a negative value's bit pattern looks nothing like its positive counterpart.
Frequently Asked Questions
Related Tools
Conversion runs in your browser with exact integer arithmetic. Nothing is uploaded.