Skip to content

Hex to RGB color converter

Convert hex colors to RGB and HSL, and back.

00
00
00
ff
  • HEX
  • RGB
  • HSL
  • HSV
  • CMYK

CMYK is a naive screen conversion, not a print profile.

WCAG contrast of this color

0 : 1 on white

    0 : 1 on black

      Ratios use the WCAG 2.2 relative luminance formula. A color with alpha is blended over white or black first.

      Runs in this browser; the colors you type are not sent anywhere.

      How do you convert hex to RGB?

      A hex color code is three numbers written in base 16 with the digits 0 to 9 and A to F. Split the six digits into pairs: the first pair is red, the second green, the third blue. Each pair is a number from 00 (0) to FF (255). To convert one pair, multiply the first digit by 16 and add the second.

      Worked example · #1E90FF
      1. Split into pairs: 1E, 90, FF.
      2. 1E is 1 × 16 + 14 = 30 (E is 14).
      3. 90 is 9 × 16 + 0 = 144.
      4. FF is 15 × 16 + 15 = 255.
      5. Result: rgb(30, 144, 255), which the tool also gives as hsl(210, 100%, 56%).
      #1E90FF split into 1E (30 of 255 red), 90 (144 of 255 green) and FF (255 of 255 blue) 1E90FF 30 red144 green255 blue 0255

      To go back, divide by 16 for the first digit and take the remainder for the second: 144 ÷ 16 = 9 remainder 0, so 90. The binary converter does the same base change for any number if you want to check a pair by hand.

      The four hex lengths

      CSS accepts four hex notations. The 3 and 4-digit forms are shorthand: each digit is doubled, so #f80 is #ff8800. The 4 and 8-digit forms add an alpha (opacity) value, where 00 is fully transparent and FF fully opaque.

      CSS hex notations
      FormExampleSame as
      #RGB #f80 #ff8800
      #RGBA #f808 #ff880088
      #RRGGBB #ff8800 rgb(255 136 0)
      #RRGGBBAA #ff880080 rgb(255 136 0 / 50.2%)

      Source: CSS Color Module Level 4, hex notations.

      Alpha of 80 in hex is 128 out of 255, which is 50.2%, not exactly 50%: 255 is odd, so there is no exact half. The tool shows alpha as a 0 to 1 number and keeps it to two decimals; for any other alpha byte, the percentage calculator gives it as a share of 255.

      Hex digits
      Hex digitDecimal
      0 0
      1 1
      9 9
      A 10
      B 11
      C 12
      D 13
      E 14
      F 15

      Source: digits A to F stand for 10 to 15.

      Four ways to write the same color

      • RGB mixes red, green and blue light, 0 to 255 each. It is what screens do, and hex is just RGB in base 16.
      • HSL (hue, saturation, lightness) describes the same color the way people do: the hue is an angle on the color wheel (0 red, 120 green, 240 blue), saturation how vivid, lightness how light. Handy for making a darker or paler version of a color by changing one number.
      • HSV (also called HSB) uses value or brightness instead of lightness. Many design tools’ color pickers work this way: full value with full saturation is the purest color.
      • CMYK is the cyan, magenta, yellow and black of printing, where inks absorb light.
      Colors in four notations
      ColorHexRGBHSL
      Black #000000 0, 0, 0 0, 0%, 0%
      White #ffffff 255, 255, 255 0, 0%, 100%
      Red #ff0000 255, 0, 0 0, 100%, 50%
      Lime #00ff00 0, 255, 0 120, 100%, 50%
      Blue #0000ff 0, 0, 255 240, 100%, 50%
      Tomato #ff6347 255, 99, 71 9, 100%, 64%
      Dodger blue #1e90ff 30, 144, 255 210, 100%, 56%
      Rebecca purple #663399 102, 51, 153 270, 50%, 40%
      Gray #808080 128, 128, 128 0, 0%, 50%

      Source: this converter. The names are standard CSS color keywords.

      Why CMYK here is only naive

      The CMYK shown is the simple textbook conversion: black is the gap between your brightest channel and 100%, and cyan, magenta and yellow are what is left over. It knows nothing about real inks, paper or a color profile such as FOGRA or SWOP, so a printer’s proof will look different, usually duller, because many bright screen colors (like pure #00ff00 or the blue above) are outside what ink can print. Treat the numbers as a starting point and ask your printer for a proper profile conversion for print work.

      The WCAG contrast ratio

      The Web Content Accessibility Guidelines (WCAG) rate text legibility by a contrast ratio from 1:1 (no difference) to 21:1 (black on white). It is worked out from each color’s relative luminance, a measure of brightness weighted for how the eye sees red, green and blue:

      Formulas · WCAG 2.2
      L = 0.2126 R + 0.7152 G + 0.0722 B

      where each channel c (0 to 1) becomes c ÷ 12.92 when c ≤ 0.04045, and ((c + 0.055) ÷ 1.055)2.4 otherwise.

      contrast = (Llighter + 0.05) ÷ (Ldarker + 0.05)
      What the ratio needs to be
      Level and useMinimum
      AA, normal text (SC 1.4.3) 4.5 : 1
      AA, large text, 18 pt or 14 pt bold (SC 1.4.3) 3 : 1
      AAA, normal text (SC 1.4.6) 7 : 1
      AAA, large text (SC 1.4.6) 4.5 : 1
      UI components and graphics (SC 1.4.11) 3 : 1

      Source: WCAG 2.2, success criteria 1.4.3, 1.4.6 and 1.4.11.

      The converter does not round up into a pass: a ratio of 4.499 counts as a fail for 4.5. Run your palette through the color blind test too; a good ratio does not help a reader who cannot tell two hues apart, so never use color alone to carry meaning.

      Contrast against white and black
      ColorNoteOn whiteOn black
      #000000 Black 21.00:1 1.00:1
      #767676 Gray, the lightest that passes AA on white 4.54:1 4.62:1
      #777777 Gray, just below 4.48:1 4.69:1
      #808080 Mid gray 3.95:1 5.32:1
      #ff0000 Pure red 4.00:1 5.25:1
      #0000ff Pure blue 8.59:1 2.44:1

      Source: calculated with the WCAG 2.2 formula.

      Colors worth knowing

      #767676 is the lightest pure gray that still passes AA for normal text on a white background (4.54:1); #777777 misses by a hair (4.48:1). Brand colors often sit right at that edge, so check the actual hex rather than judging by eye.

      Common mistakes

      • Reading #RRGGBBAA as #AARRGGBB. In CSS the alpha is last. Android and some other systems put it first.
      • Treating HSL lightness 50% as “medium brightness” for every hue. Yellow at L 50% is far brighter than blue at L 50%, which is why contrast must be checked with luminance.
      • Rounding hex from HSL by hand. HSL values with decimals do not always map to a whole RGB number; the tool rounds to the nearest whole channel.
      • Using the converted CMYK for a print job. It is not color managed.
      • Forgetting that transparent text blends with what is behind it. The contrast of a color with alpha depends on the background.

      Common questions

      What is #FFFFFF in RGB?

      rgb(255, 255, 255), which is white. #000000 is black, rgb(0, 0, 0).

      Can I type a 3-digit hex code?

      Yes. #f80 is read as #ff8800. 4 and 8-digit codes with alpha work too, with or without the # sign.

      How do I get HSL from hex?

      Type the hex code in the color box and read the HSL row. The tool first converts it to RGB, then finds the hue from which channel is largest, the lightness from the average of the largest and smallest, and the saturation from their gap.

      Does it keep what I type?

      No. Colors are converted by script in the tab; nothing is saved or sent.

      Which contrast ratio do I need?

      For normal body text, WCAG level AA needs at least 4.5:1, and AAA 7:1. Large text and UI parts need 3:1 at AA. Many accessibility laws and procurement rules cite AA.

      Sources

      Last reviewed November 9, 2026.