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.

FreeNo sign-up
RGB
rgb(31, 138, 59)
#1F8A3B is rgb(31, 138, 59): red 31, green 138, blue 59 out of 255.
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
CMYK here is a plain math conversion. Printers use color profiles, so printed colors can differ.
Show steps
  1. Split into pairs: 1F, 8A, 3B.
  2. Red: 1F = 1 × 16 + 15 = 31.
  3. Green: 8A = 8 × 16 + 10 = 138.
  4. Blue: 3B = 3 × 16 + 11 = 59.

How to use the converter

  1. Type a hex code (#1F8A3B, 1f8a3b or the short form #FA3) or three RGB numbers (31, 138, 59 or rgb(31, 138, 59)).
  2. 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.

Question 1 of 6
1. What decimal number is the hex pair FF?

Found a mistake? Let us know!

2. Convert #00FF00 to RGB.

Found a mistake? Let us know!

3. What is the hex pair for 128?

Found a mistake? Let us know!

4. The short code #F80 is the same as…

Found a mistake? Let us know!

5. How many different colors can 6-digit hex codes show?

Found a mistake? Let us know!

6. Which hex pair is 10 in decimal?

Found a mistake? Let us know!

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

Browse all calculators

More worksheets calculators

Browse all 517 calculators

Related to This Article

What people say about "Hex to RGB Converter: HEX, RGB, HSL and CMYK Color Codes"?

No one replied yet.

Leave a Reply