Hex to RGB Converter
Paste a hex code, with or without the #, and see its red, green and blue values. Each pair of hex digits is worked out on screen, so you can check it by hand.
With or without #: 3, 4, 6 or 8 digits. Any other format works too.
RGB of #E4572E
228, 87, 46
Vivid orange: red 228, green 87, blue 46 out of 255.
- HEX#E4572E
- RGBrgb(228, 87, 46)
- HSLhsl(14, 77%, 54%)
- HSVor HSBhsv(14, 80%, 89%)
- CMYKnaive, no profilecmyk(0%, 62%, 80%, 11%)
- OKLCHoklch(63.7% 0.184 36.5)
- LABCIELAB, D65lab(55.6% 52.8 50.7)
- CSS nameclosestchocolate
How this works: Method, 8 sources, Checked against 2 worked examples,
How this works
Method
A hex colour code is the three RGB numbers written in base 16, two digits each. In #1E90FF the pairs are 1E for red, 90 for green and FF for blue. Base 16 uses the digits 0 to 9 and then A to F for 10 to 15, so a pair runs from 00 (0) to FF (255), exactly the range of one 8-bit colour channel. Full method
Sources
- W3C, CSS Color Module Level 4: hex notation
- Wikipedia, Web colors
- W3C: WCAG 2.1, Success Criterion 1.4.3 Contrast (Minimum)
- W3C, WCAG 2.2: definitions of contrast ratio and relative luminance
- W3C, CSS Color Module Level 4
- Björn Ottosson (2020), A perceptual color space for image processing
- Myndex, SAPC-APCA documentation (APCA-W3 0.0.98G-4g)
- Machado, Oliveira and Fernandes (2009), A Physiologically-based Model for Simulation of Color Vision Deficiency
How it’s tested
2 worked examples for this page are checked by automated tests before every release: given the inputs, the tool must show the expected answer.
Changes
- Added eight pages: a colour picker for photos, a WCAG 2.2 and APCA contrast checker, a palette generator, a colour blindness simulator, and hex, RGB and CMYK converters.
- Redesigned: paste a colour in any format, HSV and CMYK added, opacity, a contrast check against white and black text, and colour harmonies.
- Fixed a crash when opening the colour picker.
- First published.
How to convert hex to RGB
A hex colour code is the three RGB numbers written in base 16, two digits each. In #1E90FF the pairs are 1E for red, 90 for green and FF for blue. Base 16 uses the digits 0 to 9 and then A to F for 10 to 15, so a pair runs from 00 (0) to FF (255), exactly the range of one 8-bit colour channel.
To convert a pair, multiply the first digit by 16 and add the second. 1E is 1 × 16 + 14 = 30, 90 is 9 × 16 + 0 = 144 and FF is 15 × 16 + 15 = 255, so #1E90FF is rgb(30, 144, 255), the CSS colour dodgerblue. The working above does the same for whatever code is in the box.
Short codes double each digit: #F80 is #FF8800, rgb(255, 136, 0). Codes with eight digits (or four in the short form) add an alpha pair for opacity at the end, where FF is fully opaque and 80 is about 50%. Capital and small letters mean the same thing, and the # is only there to mark the value as hex in CSS.
channel = first digit × 16 + second digit
- CSS accepts hex colours of 3, 4, 6 or 8 digits; the 4 and 8 digit forms carry an alpha channel. Source: W3C, CSS Color Module Level 4: hex notation.
- With 256 values for each of three channels, a six-digit hex code can name 16,777,216 colours. Source: Wikipedia, Web colors.
Common hex codes in RGB
Well-known colours with their hex code, RGB values and CSS name, converted by the same code as the tool.
| Hex | RGB | Colour |
|---|---|---|
| #FF0000 | rgb(255, 0, 0) | Vivid red |
| #00FF00 | rgb(0, 255, 0) | Vivid green |
| #0000FF | rgb(0, 0, 255) | Vivid blue |
| #FFFFFF | rgb(255, 255, 255) | Near white |
| #000000 | rgb(0, 0, 0) | Near black |
| #808080 | rgb(128, 128, 128) | Grey |
| #FFA500 | rgb(255, 165, 0) | Vivid orange |
| #FFD700 | rgb(255, 215, 0) | Vivid yellow |
| #800080 | rgb(128, 0, 128) | Dark purple |
| #008080 | rgb(0, 128, 128) | Dark teal |
Show all 14 rowsShow fewer
| #FFC0CB | rgb(255, 192, 203) | Light red |
| #A52A2A | rgb(165, 42, 42) | Red |
| #1E90FF | rgb(30, 144, 255) | Vivid blue |
| #2E8B57 | rgb(46, 139, 87) | Green |
Frequently Asked Questions
How do I convert #FFFFFF to RGB?
Each pair is FF, which is 15 × 16 + 15 = 255, so #FFFFFF is rgb(255, 255, 255), white. Likewise #000000 is rgb(0, 0, 0), black, and any code with three equal pairs, such as #808080, is a neutral grey.
What does a three-digit hex code mean?
It is shorthand: each digit is written twice. #09C becomes #0099CC, which is rgb(0, 153, 204). Only colours whose pairs are doubled digits can be written this way, which is why most brand colours need all six.
What are the last two digits of an eight-digit hex code?
They are the alpha, or opacity: 00 is fully transparent, FF fully opaque, and 80 (128) about half. #1E90FF80 is dodgerblue at 50% opacity, rgba(30, 144, 255, 0.5) in the older CSS syntax.
Is hex the same as RGB?
Yes, the same three numbers in a different base. Hex is compact and easy to paste; rgb() is easier to read and edit by hand. Both describe a colour in the sRGB colour space that screens and the web use.