Convert Any Decimal Number to Hex in One Click
Type a decimal number (base 10) above and this tool instantly gives you the hexadecimal (base 16) equivalent — plus binary and octal too, all at once. No sign-up, no install, no waiting.
How to Use It
- Enter your decimal number in the input field above.
- The hex result appears instantly — no button press needed.
- Click the copy icon next to any result to grab the value.
- Need to go the other way? Swap the input base to hex and type your hex value.
Worked Example: Decimal to Hex
Let's convert 255 (decimal) to hex.
The result is FF (hex). Here's how that conversion works step by step:
- 255 ÷ 16 = 15 remainder 15 → 15 in hex is F
- 15 ÷ 16 = 0 remainder 15 → 15 in hex is F
- Read the remainders from bottom to top: FF
So 255 (decimal) = FF (hex). This is one of the most common values you'll see — it's the maximum value of a single byte, used everywhere from color codes to network masks.
Quick Reference: Decimal to Hex Table
| Decimal | Hex | Binary | Octal |
|---|---|---|---|
| 0 | 0 | 0000 | 0 |
| 10 | A | 1010 | 12 |
| 15 | F | 1111 | 17 |
| 16 | 10 | 10000 | 20 |
| 32 | 20 | 100000 | 40 |
| 128 | 80 | 10000000 | 200 |
| 255 | FF | 11111111 | 377 |
| 256 | 100 | 100000000 | 400 |
| 1000 | 3E8 | 1111101000 | 1750 |
| 65535 | FFFF | 1111111111111111 | 177777 |
How to Do This in Code
If you're converting inside a script, here are the one-liners you need:
Python
# Decimal to hex in Python
decimal_value = 255
hex_value = hex(decimal_value) # returns '0xff'
hex_clean = format(decimal_value, 'X') # returns 'FF' (uppercase, no prefix)
print(hex_value) # 0xff
print(hex_clean) # FF
JavaScript
// Decimal to hex in JavaScript
const decimalValue = 255;
const hexValue = decimalValue.toString(16); // 'ff' (lowercase)
const hexUpper = decimalValue.toString(16).toUpperCase(); // 'FF'
console.log(hexValue); // ff
console.log(hexUpper); // FF
Both snippets are copy-pasteable and run exactly as shown. Python's format(n, 'X') is handy when you want clean uppercase hex without the 0x prefix.
How It Works
Decimal uses digits 0–9. Hexadecimal uses digits 0–9 plus letters A–F to represent values 10 through 15 — letting each hex digit hold 16 possible values instead of 10.
The converter repeatedly divides your number by 16, records each remainder (converting 10–15 to A–F), then reads the result in reverse. All of this runs entirely in your browser using JavaScript — your number is never sent to any server.
The tool handles very large integers beyond the normal 32-bit range without any rounding errors, making it safe for things like 64-bit memory addresses or large color palette values.
When to Use Decimal-to-Hex Conversion
- HTML/CSS colors — Color codes like
#FF5733are three hex pairs (R, G, B) each going from 00 to FF. - Memory addresses — Debuggers and hex editors display addresses in hex (e.g.,
0x7FFF5FBFF8). - Network configuration — MAC addresses are written as six hex pairs.
- File formats and protocols — Many binary formats use hex to represent byte values in docs and specs.
- Assembly and embedded programming — Register values and opcodes are almost always shown in hex.
When Hex Isn't the Right Choice
- If you need binary output (individual bits), this tool shows that too — just check the binary row in the results.
- For floating-point numbers (like 3.14), standard base conversion doesn't apply the same way. The IEEE 754 representation is different — the tool handles integers only.
- When working with negative numbers, you may need two's complement notation, which depends on the bit width (8-bit, 16-bit, etc.) — something to account for in code.
Your Data Stays Private
Everything happens locally in your browser. The number you type is never uploaded, logged, or stored anywhere. You can use it with sensitive values — IP addresses, memory dumps, internal IDs — without worry.
Related Converters and Developer Tools
If you're working with data formats alongside numeric conversions, these tools might save you time:
- JSON Beautifier - Format, Validate & Minify JSON Online — clean up minified JSON in one click.
- JSON Validator - Check & Fix JSON Errors Online (Free) — find exactly where your JSON is broken.
- JSON to YAML Converter - Convert JSON to YAML Online (Free) — switch between config formats fast.
For the authoritative definition of hexadecimal and how number bases work, see the MDN Web Docs entry on Hexadecimal.
Ready to convert? Paste or type your decimal number in the tool above and get your hex value instantly.