Hexadecimal, or hex, is a base-16 number system. It uses the digits 0 to 9 plus the letters A to F to represent values 10 to 15. One hex digit stands for four binary bits, so two hex digits describe one byte.
Quick answer: Hex is a compact, human-friendly way to write binary data. You see it in CSS colors like #A0153E, URL encoding like %20, Unicode code points like U+00E9 and error codes. Converters switch between hex, decimal, binary and text in seconds.
Key Takeaways
- Base 16: Digits 0 to 9 and A to F.
- Compact binary: One hex digit equals four bits.
- Two digits per byte: Values from 00 to FF.
- Common in web work: Colors, URLs and character codes.
- Case doesn’t matter: #a0153e and #A0153E are the same.
Hex, Decimal and Binary
| Hex | Decimal | Binary |
|---|---|---|
| 0 | 0 | 0000 |
| 9 | 9 | 1001 |
| A | 10 | 1010 |
| F | 15 | 1111 |
| 20 | 32 | 0010 0000 |
| FF | 255 | 1111 1111 |
MDN’s hex color reference explains how CSS hex colors use pairs of hex digits for red, green and blue.
Why Hexadecimal Matters
Hex is everywhere in web work. Brand colors are shared as hex codes, URLs encode special characters as hex after a % sign and developer tools show data in hex.
Understanding hex makes these easier to read. When you see %2F in a URL, you can recognize 2F as 47, which is the slash character. When a color is #FFFFFF, you know all three channels are at their maximum of 255, making white.
How to Work With Hex
Step 1: Read Hex Colors
Split a six-digit code into three pairs: red, green and blue.
Check: You can tell #FF0000 is pure red.
Step 2: Convert Colors
Use hex to RGB or RGB to hex converters.
Check: Both formats show the same color.
Step 3: Convert Hex to Decimal
Use a hex to decimal converter for numbers.
Check: FF becomes 255.
Step 4: Decode Hex Text
Paste hex bytes into a hex to text converter.
Check: 48 69 becomes “Hi”.
Step 5: Recognize Hex in URLs
Read % codes as hex character values.
Check: You can spot %20 as a space.
An Illustrative Example
A designer receives brand colors as RGB values, but the WordPress theme settings only accept hex codes. Converting each color gives six-digit codes like #A0153E.
The designer pastes the codes into the theme, and the site’s buttons and headings now match the brand guidelines exactly.
Myths vs Reality
- Myth: Hex is only for programmers. Reality: Designers use hex colors daily.
- Myth: Letters make hex complicated. Reality: A to F are just 10 to 15.
- Myth: Three-digit colors are different. Reality: #F00 is shorthand for #FF0000.
Convert Hex to RGB
Turn any hex color into RGB values for your design tools.
Common Use Cases
- Brand colors: Sharing exact colors between designers and developers.
- URL encoding: Characters like %2F use hex codes.
- Unicode: Code points like U+00E9 are written in hex.
- Debugging: Inspecting raw bytes in files.
- Hashes and IDs: MD5, SHA and UUID values are hex strings.
Do It Yourself or Get Help
Color and number conversions are quick with free converters. Developers handle hex when debugging binary data or file formats.
Quick Tip
Store your brand colors as hex codes in one shared place, like a style guide or theme settings. That way designers, developers and marketers all use the exact same values, and colors stay consistent across the site.
Mistakes to Avoid
- Missing the # in CSS: Colors need it.
- Using invalid letters: Only A to F are valid.
- Confusing hex with decimal: 10 in hex is 16.
- Wrong digit count: Colors use 3, 4, 6 or 8 digits.
- Forgetting alpha: Eight-digit codes include transparency.
FAQ
What Is Hexadecimal?
A base-16 number system using 0 to 9 and A to F.
Why Are Colors Written in Hex?
Hex is a compact way to write the 0 to 255 values of red, green and blue.
What Is FF in Decimal?
255.
What Does 0x Mean?
A prefix used in programming to show a number is hex.
How Do I Convert Hex to Binary?
Convert each hex digit to four bits.
What Is an Eight-Digit Hex Color?
A color with an extra pair for transparency.
Why Is Hex Called Base 16?
It uses 16 distinct digits.
What Is #FFF?
Shorthand for #FFFFFF, which is white.
Where to Go Next
- Base 2: Read about binary.
- Base 8: Learn about octal.
- Character codes: See ASCII.
- URL codes: Read about URL encoding.
