ToolsHub4u

Pick a colour and copy HEX, RGB or HSL

Pick a colour with the native control or paste a hex, RGB, HSL or named value. The page returns every format, two tint swatches and the WCAG contrast of the colour on white and black.

  • HEX, RGB, HSL
  • Contrast check
  • No uploads
Ready Developer & Utility
1Enter
2Adjust
3Copy result

Colour Picker

1

Colour

Use the picker or type a value such as #2f6f5e, #2f6, rgb(47 111 94) or hsl(166 41% 31%).

No data yet Live
2

Values and contrast

Converted #2f6f5e to #2f6f5e.

HEX

#2f6f5e

Colour sample
Base#2f6f5ehex #2f6f5e, rgb 47 111 94
20% lighter#598c7emixed with white
20% darker#26594bmixed with black
  • Best contrast is 5.91:1Passes AA for normal text, but not AAA.
  • Alpha is not modelledAn 8-digit hex value is shown with FF alpha. Contrast is calculated for the opaque colour, so a translucent colour over a background will differ.
Colour values
FormatValue
HEX#2f6f5e
RGBrgb(47, 111, 94)
HSLhsl(164 10329% 31%)
Relative luminance0.128
Contrast on white
5.91:1
Contrast on black
3.56:1
Normal text
AA
Large text
AAA

Conversions use the sRGB colour space. HSL is a representation of the same colour, not a different one. Contrast follows the WCAG 2 relative-luminance formula, rounded to two decimals.

This page reads a colour value and returns the same colour in hex, RGB and HSL, with two tint swatches and a WCAG contrast check against white and black. Type a value, use the colour field, or paste the hex you copied from a design file. The sample, the conversion table and the contrast badges update together.

It accepts hex with three, four, six or eight digits, rgb() and rgba() with commas, spaces or a slash, hsl() or hsla(), and the standard CSS colour names including rebeccapurple and transparent. Alpha is read from a four or eight digit hex, from rgba() or from a slash value. The result is calculated locally and is not stored.

Values it reads

Hex is the most predictable input. Three digits are expanded, so #2f6 becomes #22ff66. Six digits are read as red, green and blue. Four and eight digits carry an alpha pair, and the page keeps it: #2f6f5e80 stays at half opacity rather than being flattened to #2f6f5e. The alpha pair is converted on a 0 to 255 scale, so 80 becomes 0.5.

The RGB parser accepts numbers from 0 to 255 and percentages, with commas, whitespace or a slash before the alpha. Both the legacy rgba(47, 111, 94, 0.4) form and the modern rgb(47 111 94 / 40%) form work. The HSL parser accepts a hue in degrees and saturation and lightness as percentages, with or without commas. Values outside the valid range are clamped, so a saturation of 140% is treated as 100%, and a value it cannot parse produces a failure message instead of a guessed colour.

CSS names are looked up rather than rejected. rebeccapurple becomes #663399 and tomato becomes #ff6347. transparent is treated as black at zero alpha, which is what the keyword means in CSS. Names are case-insensitive, and the output is always the numeric equivalent.

How the contrast check works

The contrast ratio follows the WCAG 2 formula. Each sRGB channel is converted to linear light, the three channels are weighted by 0.2126, 0.7152 and 0.0722 to get relative luminance, and the ratio is (lighter + 0.05) / (darker + 0.05). The page calculates the ratio against pure white and pure black and shows both, rounded to two decimal places.

When the colour is translucent, it is composited over each background first. A half-opacity red over white is a pale pink, and the ratio shown is the ratio of that blended result, not of opaque red. This is the number a reader actually sees, and it is why the same hex can pass on black and fail on white. The relative-luminance row always describes the opaque colour and is labelled that way when alpha is present.

The badges use the better of the two ratios. Normal text passes AA at 4.5:1 and AAA at 7:1. Large text passes AA at 3:1 and AAA at 4.5:1. Large here means at least 18pt, or 14pt bold, which is roughly 24px or 18.66px bold. The badges do not know your font size, so a large-text pass is only relevant if the text really is that large.

A worked example

The hex #2f6f5e produced the values below. Its relative luminance is 0.128, which gives 5.91:1 against white and 3.56:1 against black.

Conversion and contrast results for four example colours
InputHEXHSLWhiteBlack
#2f6f5e#2f6f5ehsl(164 41% 31%)5.91:13.56:1
hsl(166 41% 31%)#2f6f60hsl(166 41% 31%)5.89:13.56:1
rebeccapurple#663399hsl(270 50% 40%)8.41:12.5:1
#2f6f5e80#2f6f5e80hsl(164 41% 31%)2.17:11.64:1

The first row is the ordinary case: the hex round-trips, the HSL saturation is the expected 41%, and the colour passes AA for normal text on white. The second row shows that HSL input and HSL output now agree, because the saturation is normalised once rather than twice.

The named colour is the convenience case. Typing a name you know is faster than looking up its hex, and the page resolves it to #663399 before doing the same contrast maths. The last row is the transparency case: half-opacity green has only 2.17:1 on white once it is blended, so it fails both text levels even though the opaque hex passes. That difference is the reason alpha is included rather than ignored.

Transparency changes the ratioA colour that passes at full opacity can fail once it is translucent, because the background shows through. Check the blended figure, not the hex alone.

Alpha, swatches and copying

The alpha checkbox changes the primary value and the HEX row to eight digits. When the input already has an alpha pair, that pair is preserved; when the colour is opaque, the checkbox writes ff. The checkbox does not change the colour or the contrast figures, because those already account for the alpha in the input.

The two swatches mix the opaque colour with white and black at 20%. They are a quick way to see a lighter and darker step, not a full tint scale, and they do not inherit transparency. The copy button writes a short text report and a :root block with the hex value, the RGB channels as space-separated numbers, and the HSL value. A translucent colour also gets a --colour-alpha line so the custom property set is complete.

If you are choosing a palette rather than checking one colour, work in the other direction: decide the contrast pair first, then pick the colour. The gradient generator uses the same hex values, and the box shadow generator accepts a six-digit hex for the shadow colour.

Questions

Common questions

Short answers about this tool and its limits.

Does it accept named CSS colours?

Yes. The standard names are looked up, so rebeccapurple becomes #663399 and tomato becomes #ff6347. Names are case-insensitive, and transparent is treated as black at zero alpha.

What do the AA and AAA badges mean?

They are WCAG contrast levels. Normal text needs 4.5:1 for AA and 7:1 for AAA. Large text needs 3:1 for AA and 4.5:1 for AAA. The badge uses the better of the white and black results.

Is the contrast checked against my page background?

No. It checks pure white and pure black only. A tinted background changes the ratio, so calculate the pair you will actually ship. The two figures are a quick screen, not a guarantee for every surface.

Does alpha affect the contrast result?

Yes. A translucent colour is blended over white and over black before the ratio is calculated, so the result matches what a reader sees on that background. Half-opacity #2f6f5e scores 2.17:1 on white instead of 5.91:1.

Why does an eight-digit hex keep its last pair?

Because it is the alpha. #2f6f5e80 is about half opacity, and that value is preserved in the output and used in the contrast blend. The alpha checkbox only forces an explicit pair, writing ff when the colour is opaque.

Which input formats are accepted?

Hex with 3, 4, 6 or 8 digits, CSS colour names, rgb() and rgba() with commas, spaces or a slash, and hsl() or hsla() with a degree hue and percentage saturation and lightness. Out-of-range channels are clamped.

Why are the tint swatches opaque?

The swatches mix the base RGB channels with white and black, so they show a solid lighter and darker step. They do not apply the input alpha. Use the sample panel, which does honour transparency, to judge the translucent colour.

Is the colour saved anywhere?

No. The conversion runs in the browser and there is no history or account. Copy the values or download the text report before closing the tab.