HEX RGB HSL Color Converter

Enter a color code to see HEX, RGB and HSL and the contrast ratio right away.

AD

Convert a color code

e.g. #0E6E5C

Please check the color code, e.g. #0E6E5C

#0E6E5C
#0E6E5C
rgb(14, 110, 92)
hsl(169, 77%, 24%)

RGB (0~255)

HSL (H° / S% / L%)

HSL values are rounded to whole numbers, so converting back to RGB can drift by 1–2 steps.

Recent colors

Web accessibility contrast check (WCAG)

Please check the color code, e.g. #0E6E5C

Please check the color code, e.g. #FFFFFF

6.16 : 1

AA normal text (4.5:1)-
AA large text (3:1)-
AAA normal text (7:1)-
AAA large text (4.5:1)-

Sample text AaBb 123

Sample text AaBb 123

Large text means 18 pt (about 24 px) or bigger, or 14 pt (about 18.66 px) and bold.
WCAG sets a minimum, not a guarantee. Always check the result with your own eyes on a real screen.

How the conversion is calculated

See the formula and a worked example

How the conversion works, and the formulas

HEX, RGB and HSL are just three ways of writing the same color. HEX uses six hexadecimal digits such as #RRGGBB, RGB uses the amounts of the three primary lights (red, green and blue) such as rgb(r, g, b), and HSL uses hue, saturation and lightness such as hsl(h, s%, l%). For example, converting #0E6E5C to RGB gives 0×16+14=14 for the first pair 0E, 6×16+14=110 for the middle pair 6E, and 5×16+12=92 for the last pair 5C, so the result is rgb(14, 110, 92). RGB treats a color as three amounts of light, while HSL shifts to three more intuitive axes: hue, vividness and lightness. That is why HSL makes it much easier to keep a color and adjust only its brightness by changing the L value.

How to use

1Enter a color code — paste it into the HEX box or click the swatch to pick one.
2See all three codes at once — HEX, RGB and HSL change together, and each Copy button takes the code with you.
3Check contrast — enter a text color and a background color and badges show whether they pass WCAG.
AD

How the color converter works

This color converter turns a HEX code into RGB and HSL (and back again) as you type. Paste a code such as #0E6E5C, drag the swatch, or type into the RGB or HSL boxes, and every notation, the preview and the copy-ready code lines update together. A WCAG contrast checker sits below, so one page covers both jobs.

HEX, RGB and HSL are three ways to write one color

A screen mixes red, green and blue light. RGB writes each channel as a number from 0 to 255. HEX writes the same three numbers in base 16, two digits per channel, with a leading #. HSL uses hue (0 to 360 degrees), saturation (0 to 100 percent) and lightness (0 to 100 percent).

#RRGGBB → R = hex(RR), G = hex(GG), B = hex(BB)

Worked example with #0E6E5C. The first pair, 0E, is 0 × 16 + 14 = 14. The middle pair, 6E, is 6 × 16 + 14 = 110. The last pair, 5C, is 5 × 16 + 12 = 92. So the color is rgb(14, 110, 92), or hsl(169, 77%, 24%).

How the contrast ratio is calculated

WCAG defines contrast as the ratio between the relative luminance of the lighter and darker color. Relative luminance is a weighted sum of the linearized red, green and blue channels: about 21 percent red, 72 percent green and 7 percent blue.

L = 0.2126 × R + 0.7152 × G + 0.0722 × B   |   ratio = (Llighter + 0.05) ÷ (Ldarker + 0.05)

The ratio runs from 1:1 (identical colors) to 21:1 (black on white). #0E6E5C on white measures about 6.2:1, above the 4.5:1 line. Mid-gray on white is a common edge case: #777777 measures 4.48:1 and fails AA for normal text by a hair, while #767676 measures 4.54:1 and just passes.

WCAG contrast levels

TextAAAAA
Normal4.5:17:1
Large3:14.5:1

Large means 18 pt (about 24 px) or larger, or 14 pt and bold. AA is what most organizations target for body copy; AAA is the stricter, enhanced level for long-form reading.

Common mistakes

  • Shortening a HEX code that cannot be shortened. #AABBCC can be written #ABC because each pair repeats a digit. #A1B2C3 cannot, and shortening it silently gives a different color.
  • Trusting your own eyes for light gray text. Pale caption text can look fine on a monitor and fail on a phone in sunlight. WCAG 2.1 also asks for at least 3:1 contrast on icons, input borders and focus indicators.

Frequently asked questions

Are a HEX code and an RGB value the same color?

Yes. HEX and RGB are two ways of writing the same three numbers, one in base 16 and one in base 10. #0E6E5C and rgb(14, 110, 92) are identical.

What does the # in a color code mean, and can I use three digits?

The # marks a hexadecimal color. When both digits in every pair are the same, you can shorten the code to three digits, so #00ff88 becomes #0f8 in short form. If any pair has two different digits, it cannot be shortened.

Why does converting HSL back to RGB sometimes change a value by one or two?

HSL is shown as whole numbers, so the hue, saturation and lightness are rounded. Turning it back into RGB can land one or two steps away, so keep the HEX or RGB value as your source of truth.

What contrast ratio do I need for text on a website?

For WCAG Level AA, body text needs at least 4.5:1 and large text needs at least 3:1. For Level AAA, the numbers are 7:1 and 4.5:1. If you are not sure, aim for AA on everything and AAA for long reading passages.

What counts as large text?

Text that is at least 18 point (roughly 24 pixels), or at least 14 point (roughly 18.66 pixels) and bold. Anything smaller needs the higher ratio.

Is anything I enter stored or uploaded?

No. The conversions and contrast checks run in your browser. The only thing saved is a short list of recent colors in your own browser storage, and you can clear it with one click.

Related tools

AD

How this tool is checked

Last regular check

How it calculates HEX pairs are read as base-16 RGB channel values, converted to HSL, and contrast uses the WCAG relative-luminance ratio.

How we check Before release, results go through calculation regression tests plus screen and accessibility checks, and the check date changes only when these checks pass again.

Run by Toolssok · About · Report an error