Decimal ↔ Hexadecimal Converter
Convert between decimal (base 10) and hexadecimal (base 16) instantly
Decimal is the everyday number system (0-9). Hexadecimal is used extensively in computing — for colour codes (#FF5733), memory addresses, and debugging. This converter helps you switch between both systems instantly.
Loading calculator...
How It Works
The Decimal-Hex Formula
How to convert between decimal and hexadecimal
Formula
Hex = Decimal ÷ 16 repeated (remainders) | Decimal = Σ(Hex digit × 16^position)
Variables
Powers of 16
Hexadecimal is base-16, so each digit represents a power of 16. The rightmost digit is 16⁰ (value 1), next is 16¹ (16), then 16² (256), 16³ (4096), and so on.
Hexadecimal Digits
Hex uses 0-9 for values 0-9 and A-F for values 10-15. A = 10, B = 11, C = 12, D = 13, E = 14, F = 15.
Decimal to Hex Conversion
Repeatedly divide the decimal number by 16, recording remainders (0-15, with 10-15 converted to A-F). Read remainders from bottom to top.
Note: Decimal to hex conversion is essential for web development, where colour codes are expressed in hex (e.g., rgb(255, 87, 51) → #FF5733). Memory addresses and debugging tools also use hex extensively.
Step-by-Step Example
Converting decimal 255 to hexadecimal
Divide 255 by 16
255 ÷ 16 = 15 remainder 15
Convert remainders to hex
15 in decimal = F in hex
Divide quotient 15 by 16
15 ÷ 16 = 0 remainder 15
Convert remainder to hex
15 in decimal = F in hex
Read remainders from bottom to top
Bottom reminder: F (15), Top remainder: F (15) → FF
Result
Decimal 255 = Hexadecimal FF
Reference Guide
| unit | value | note |
|---|---|---|
| Decimal 0 | Hex 0 | Black |
| Decimal 255 | Hex FF | White in RGB |
| Decimal 255,0,0 | #FF0000 | Pure Red |
| Decimal 0,255,0 | #00FF00 | Pure Green |
| Decimal 0,0,255 | #0000FF | Pure Blue |
Understanding Hexadecimal Colours
How RGB colour codes work
RGB (Red, Green, Blue) colours are represented as three values from 0-255. In hex, each colour component becomes a two-digit hex number (00-FF). Hex colour codes are written as #RRGGBB.
Best for: Example: #FF0000 = red, #00FF00 = green, #0000FF = blue, #FFFFFF = white, #000000 = black
Memory addresses in debuggers and crash dumps are almost always displayed in hexadecimal. This makes them more compact and easier to read than binary.
Best for: Example memory address: 0x7FFD8A3F2B1C (the 0x prefix indicates hex).
All colours in HTML and CSS can be represented as hex values. Design tools often display colours in both hex (#FF5733) and RGB (255, 87, 51).
Best for: Figma, Photoshop, and Illustrator all show both decimal RGB and hex colour codes for easy conversion.
Why Hexadecimal Is Used for Colours and Memory
Hexadecimal (base 16) is used extensively in web development and computing because it maps perfectly to the 8-bit byte (0-255). One byte equals exactly two hex digits — FF = 255, 00 = 0. In web design, colours are often defined using the RGB (Red, Green, Blue) model, where each colour component ranges from 0 to 255. In hex, these three numbers become a six-digit code: #RRGGBB. For example: - RGB(255, 0, 0) = #FF0000 (pure red) - RGB(0, 255, 0) = #00FF00 (pure green) - RGB(0, 0, 255) = #0000FF (pure blue) - RGB(255, 255, 255) = #FFFFFF (white) - RGB(0, 0, 0) = #000000 (black) This gives exactly 16.7 million possible colours (256³). Hexadecimal is also used in memory addressing because it's more compact than binary and every modern processor uses 8-bit bytes (2 hex digits) at minimum. Converting decimal to hex is also common when working with: - IP addresses (though they use decimal dotted notation, not hex) - Digital electronics - Low-level programming - Character encoding (ASCII values in hex)
Key Features
💡 Pro Tips
- →Web colour hex codes are always 6 digits: #RRGGBB. Two digits per colour (00 to FF).
- →Some design tools use 3-digit hex shorthand: #F00 = #FF0000 (red) when each pair has identical digits.
- →Memory addresses in debuggers often use the '0x' prefix. 0xFF = 255 decimal.
- →The maximum value for one colour component is FF (255 decimal).
- →Common hex values to memorise: FF=255, CC=204, 99=153, 66=102, 33=51
Common Mistakes
Forgetting to convert each colour component separately in RGB
RGB colour is three separate values (0-255 each). Convert each one to hex individually, then concatenate with # in front.
Entering letters beyond A-F in hex input
Hexadecimal only uses letters A-F (10-15). G-Z are not valid and will cause an error.
Mixing up 16 and 10 in conversion
Hexadecimal is base-16 (not base-10). Make sure you're dividing by 16, not 10, when converting decimal to hex.
Research & Citations
All factual claims on this page are sourced from peer-reviewed research
- [1]
World Wide Web Consortium (W3C) (2018). CSS Color Module Level 4. W3C.org.
Official specification for colour representation in CSS, including hex notation (#RRGGBB)
View source
This calculator is a reference tool and does not constitute medical advice. For personalised sleep health guidance, consult a qualified healthcare provider.
Last updated: January 10, 2025
Creators
Developer
Table of Contents
Quick Facts
Related Tools
Privacy Guaranteed
Your data never leaves your browser. All calculations are 100% private.
Frequently Asked Questions
How do I convert decimal to hexadecimal?
Repeatedly divide the decimal number by 16, recording remainders. Convert remainders 10-15 to A-F. Read remainders from bottom to top. Example: 255 decimal ÷ 16 = 15 remainder 15 → FF hex.
How do I convert hexadecimal to decimal?
Multiply each hex digit by 16 raised to its position (starting 0 on the right). A=10, B=11, C=12, D=13, E=14, F=15. Example: FF hex = 15×16 + 15 = 255 decimal.
What is the hex code for white?
White in RGB is R=255, G=255, B=255. 255 decimal = FF hex. So white in hex is #FFFFFF.
What is the difference between hex and RGB colours?
RGB colours are decimal values (0-255). Hex colours are the same values but in base-16 (00-FF). They represent exactly the same colour — #FF0000 = rgb(255,0,0) = red. They're just different representations.
What does the # mean in #FF5733?
The '#' prefix indicates that the following number is a hexadecimal colour code in HTML/CSS. It is not part of the hex value itself — it's a marker.