Dev Toolbox · Windows 10 and 11
Convert HEX to RGB and HSL
Type a color as #FF4A3D, rgb(), hsl() or a name like teal, or pick it from a palette, and get the same color in HEX, RGB and HSL, ready to paste into CSS. The contrast ratio against white and against black comes with it, so you know at once which text color reads well on it.
How to convert HEX to RGB
- 1
Open the Color converter
In the Dev Toolbox, choose Color converter, the first tool in the Color group.
- 2
Enter a color
Type it into Color: a hex code with its #, rgb(255, 74, 61), hsl(4, 100%, 62%) or a CSS name. Or click the swatch under Pick and choose one.
- 3
Read the conversions
A preview swatch appears with HEX, RGB and HSL, then Contrast on white and Contrast on black.
- 4
Copy a value
Press Copy next to the format you need and paste it into your stylesheet, design tool or code.
How a hex color code maps to RGB
A hex color is three numbers squeezed together. In #FF4A3D the pairs are FF, 4A and 3D: red, green and blue, each from 00 to FF in hexadecimal, which is 0 to 255 in decimal. So #FF4A3D is rgb(255, 74, 61): full red, a little green, slightly less blue.
- Short form. #F80 doubles each digit and means #FF8800.
- With alpha. A fourth pair sets the opacity: #FF4A3D80 is the same color at about 50% (80 in hex is 128 of 255). Octoolo shows a see-through color as an 8-digit HEX and as RGBA and HSLA.
- The # matters. Type the code with its # sign; FF4A3D on its own is not read as a color.
Each pair is one byte, so six hex digits hold 256 × 256 × 256 = 16,777,216 colors. For converting other numbers between hex and decimal, use the number base converter.
RGB or HSL: which to use
RGB says how much of each light to mix, which is how screens work and how most design tools export colors. HSL describes a color the way people think about it:
- Hue, an angle on the color wheel from 0 to 360: 0 is red, 120 green, 240 blue.
- Saturation, from 0% (gray) to 100% (full color).
- Lightness, from 0% (black) through 50% (the pure color) to 100% (white).
That makes HSL handy for building a palette in CSS: keep the hue, change the lightness, and you get lighter and darker shades of one color for hover states, borders and backgrounds. Octoolo rounds HSL to whole numbers, so a color taken to HSL and back can come out a shade different in the last digit.
The named colors of CSS, from aliceblue to yellowgreen, convert too, which is a quick way to learn what tomato or steelblue really are.
Contrast ratios and WCAG
For each color, Octoolo shows the WCAG contrast ratio against white and against black. Ratios run from 1:1 (no contrast) to 21:1 (black on white). They compare the relative luminance of two colors, how bright each looks to the eye, which weighs green far more than blue.
| Used for | WCAG AA | WCAG AAA |
|---|---|---|
| Body text | 4.5:1 | 7:1 |
| Large text (24 px, or 18.66 px bold) | 3:1 | 4.5:1 |
| Icons and the edges of inputs and buttons | 3:1 | No level set |
Take #FF4A3D: 3.33:1 on white, 6.30:1 on black. White text on that red passes only at large sizes, while black text passes AA at any size. A classic case among grays: #777777 reaches 4.48:1 on white and just misses AA, while #767676, one step darker, passes at 4.54:1.
The ratio is worked out from the solid color. For a see-through color, the real contrast depends on what shows through it, so check the color it turns into on the page.
Where the colors come from
Most color codes you need are already somewhere: in a brand guide, a stylesheet, a screenshot. To take one from a picture, the Photo Editor's color picker copies the hex code of any pixel you click; paste it here for RGB, HSL and contrast. Microsoft PowerToys, a separate download for Windows, also has a Color Picker (Win Shift C) that grabs any pixel on screen.
This converter covers screen colors. It has no CMYK: print colors depend on the printer and paper profile, so ask your print shop for those values. It has no HSV or HSB either, the model behind Photoshop-style pickers. For QR codes in brand colors, the QR code generator takes a dot and a background color, and the contrast figures here help keep the code easy to scan.
Questions, answered
How do I convert HEX to RGB by hand?
Split the six digits into three pairs and turn each pair into decimal: the first digit times 16, plus the second, with A to F as 10 to 15. 4A is 4 × 16 + 10 = 74.
Should I put white or black text on my color?
Pick whichever of the two contrast rows is higher. If both are under 4.5:1, the color is too mid-toned for small text either way: darken or lighten it in HSL until one side passes.
Does it work with transparent colors?
Yes. rgba(), hsla() and 8-digit hex keep their alpha, shown as a fourth value in each format. The contrast rows ignore transparency.
Can it convert to CMYK or Pantone?
No. It converts between the screen formats HEX, RGB and HSL. Print values need the printer's color profile, and Pantone matches need Pantone's own guides.
Which color names does it understand?
All the named colors of CSS, such as navy, coral, rebeccapurple and lightgoldenrodyellow, in any mix of upper and lower case. A name it does not know gets a short message instead of a result.
HEX to RGB, and 16 more apps.
Download for Windows7 days free, then from $3.99 a month for all 17 apps. Windows 10 and 11.