Hex to RGB Converter
WorksheetsFreeNo sign-up
A hex color is three pairs of base-16 digits for red, green and blue. #1F8A3B splits into 1F, 8A and 3B, which are 31, 138 and 59 in decimal: rgb(31, 138, 59). Type a hex code or an rgb() value to convert it.
| Color codes | |
| HEX | #1F8A3B |
| RGB | rgb(31, 138, 59) |
| RGB percent | rgb(12.2%, 54.1%, 23.1%) |
| HSL | hsl(136, 63%, 33%) |
| CMYK (simple conversion) | 78%, 0%, 57%, 46% |
| Decimal | 2,067,003 |
| Contrast | |
| Contrast with white | 4.41:1 |
| Contrast with black | 4.76:1 |
| Better text color on it | black |
Show steps
- Split into pairs: 1F, 8A, 3B.
- Red: 1F = 1 × 16 + 15 = 31.
- Green: 8A = 8 × 16 + 10 = 138.
- Blue: 3B = 3 × 16 + 11 = 59.
How to use the converter
- Type a hex code (#1F8A3B, 1f8a3b or the short form #FA3) or three RGB numbers (31, 138, 59 or rgb(31, 138, 59)).
- Press Calculate or Enter. You get HEX, RGB, HSL and CMYK, a preview, and the contrast with white and black.
How hex to RGB works
Hex is base 16, using the digits 0 to 9 and A to F (A = 10, …, F = 15). Each pair of digits is one color channel from 00 (0) to FF (255). To convert a pair, multiply the first digit by 16 and add the second:
- 1F = 1 × 16 + 15 = 31
- 8A = 8 × 16 + 10 = 138
- 3B = 3 × 16 + 11 = 59
To go back, divide each RGB number by 16: the whole-number part is the first hex digit and the remainder is the second. 138 ÷ 16 = 8 R 10, which is 8A.
Common colors
| Color | HEX | RGB |
|---|---|---|
| Black | #000000 | 0, 0, 0 |
| White | #FFFFFF | 255, 255, 255 |
| Red | #FF0000 | 255, 0, 0 |
| Lime | #00FF00 | 0, 255, 0 |
| Blue | #0000FF | 0, 0, 255 |
| Yellow | #FFFF00 | 255, 255, 0 |
| Gray | #808080 | 128, 128, 128 |
| Orange | #FFA500 | 255, 165, 0 |
Hex and RGB practice questions
Test yourself with 6 multiple-choice questions. Choose an answer and press Submit to see if you are right and why. Your score appears at the end.
Quiz complete
Frequently asked questions
How do you convert hex to RGB?
Split the code into three pairs and change each from base 16 to base 10 by multiplying the first digit by 16 and adding the second. #FF8800 is 255, 136, 0.
How do you convert RGB to hex?
Divide each number by 16. The quotient is the first hex digit and the remainder is the second (using A to F for 10 to 15). 200 ÷ 16 = 12 R 8, which is C8.
What is a 3-digit hex code?
A shorthand where each digit is repeated. #ABC means #AABBCC. Only colors whose pairs have two equal digits can be written this way.
Is hex the same as HTML color code?
Yes. HTML and CSS use hex codes such as #1F8A3B, and also accept rgb(), hsl() and color names.
Sources
Related calculators
- Color Contrast Checker
- Binary, Decimal and Hexadecimal Converter
- Remainder Calculator
- QR Code Generator
More worksheets calculators
Related to This Article
More math articles
- The Best Grade 3 Math Book for Alaska Students
- How to Make Math into a Fun Experience
- The Ultimate TNReady Algebra 1 Course (+FREE Worksheets)
- Party platforms
- The Best SAT Math Book for Students Starting From the Basics
- A Guided, Timed Response
- Rhode Island Algebra 1 Free Worksheets: Printable Algebra 1 Practice, Fully Worked Keys
- Maine Through Year Calculator Policy: Rules by Grade
- Free Grade 8 English Worksheets for Oregon Students
- 10 Most Common 8th Grade IAR Math Questions












What people say about "Hex to RGB Converter: HEX, RGB, HSL and CMYK Color Codes"?
No one replied yet.