Toolvito

Works on this device

Color Code Converter

Type a colour in one notation and get it in all the others: hex, RGB, HSL, HSV, HWB, CMYK, CIE Lab, LCh, OKLab and OKLCH. The tool also reads CSS colour names, colour numbers and colour temperatures.

Enter your values

Type or paste a colour in any common form. You get hex, RGB, HSL, CMYK, Lab and more.

Your values

Hex, rgb(), hsl(), hwb(), lab(), lch(), oklab(), oklch() or a CSS colour name. Three numbers such as 51, 102, 204 are read as RGB.

Your values are worked out in this browser. They are not sent to a server.

Your result will show here

Fill in the values, then choose Convert.

How to use this converter

  1. Choose what you want to convert. Any colour code to every notation reads most forms, so it is a good place to start.
  2. Type or paste the colour. For example #3366cc, rgb(51, 102, 204), hsl(220 60% 50%) or royal blue.
  3. The result follows your typing. The first lines give the main answers. Under them is a sample of the colour with its code beside it, and then a table with the same colour in every notation.
  4. Choose Copy result or Download CSV to keep the values.

What the notations mean

  • Hex writes red, green and blue as three pairs of hex digits, each from 00 to ff (0 to 255). #3366cc is red 51, green 102, blue 204. A fourth pair is the opacity.
  • RGB gives the same three numbers in decimal. CSS also takes percentages and a form with spaces.
  • HSL and HSV (HSB) describe the colour by its hue angle on a circle, its saturation, and its lightness or brightness. HWB uses hue, whiteness and blackness.
  • CMYK gives ink amounts for cyan, magenta, yellow and black. This tool uses only the naive formula. Read the part about CMYK below.
  • CIE XYZ, L*a*b* and LCh are device-independent values. L*a*b* needs a white point: the table gives it for D65 and for D50. CSS lab() and lch() use D50.
  • OKLab and OKLCH are newer spaces made so that equal steps look more even. CSS has oklab() and oklch().

The formulas

  • sRGB follows IEC 61966-2-1. A channel c from 0 to 1 becomes linear light as c ÷ 12.92 when c is 0.04045 or less, and as ((c + 0.055) ÷ 1.055) to the power 2.4 above that.
  • XYZ comes from linear RGB through the sRGB matrix. The tool works that matrix out from the sRGB primaries and the D65 white (x = 0.3127, y = 0.3290). Its first row is 0.4124, 0.3576, 0.1805 when rounded.
  • L*a*b* uses the CIE formulas with the constants 216/24389 and 24389/27. For D50 the XYZ values are first adapted from D65 with the Bradford method.
  • OKLab uses the matrices that Björn Ottosson published in 2020.
  • HSL: lightness = (max + min) ÷ 2, saturation = (max − min) ÷ (1 − |2 × lightness − 1|). HSV: value = max, saturation = (max − min) ÷ max. The hue is the same in both.
  • Naive CMYK: K = 1 − max(R, G, B). Then C = (1 − R − K) ÷ (1 − K), M = (1 − G − K) ÷ (1 − K), Y = (1 − B − K) ÷ (1 − K).
  • Opacity over a background: result = top × opacity + background × (1 − opacity) for each channel.

RGB and CMYK: the difference

RGB is for light. A screen adds red, green and blue light, and all three at full strength give white. CMYK is for ink. Cyan, magenta and yellow ink take light away from white paper, and black ink (K) is added for dark tones and sharp text.

There is no single correct way to turn RGB into CMYK. The printed colour depends on the press, the inks and the paper. Print software uses an ICC profile of the press to do the conversion, and some bright screen colours cannot be printed at all.

The CMYK numbers of this tool come from the naive formula only. They are fine for learning and for a rough start. Do not use them as final print values, and do not expect a match to any print standard. Ask your printer which profile to use.

Worked example

Take #3366cc. The pairs are 33, 66 and cc. In decimal that is red 51, green 102 and blue 204, so the colour is rgb(51, 102, 204).

On the 0 to 1 scale the channels are 0.2, 0.4 and 0.8. The largest is 0.8 and the smallest is 0.2. Lightness = (0.8 + 0.2) ÷ 2 = 0.5. Saturation = 0.6 ÷ (1 − 0) = 0.6. Blue is the largest channel, so hue = 60 × ((0.2 − 0.4) ÷ 0.6 + 4) = 220°. The result is hsl(220, 60%, 50%).

Naive CMYK: K = 1 − 0.8 = 0.2. C = (1 − 0.2 − 0.2) ÷ 0.8 = 0.75, M = (1 − 0.4 − 0.2) ÷ 0.8 = 0.5, Y = 0. That is 75%, 50%, 0%, 20%.

Colour names

CSS has 148 colour names with fixed values, such as teal (#008080), navy (#000080) and hotpink (#ff69b4). The tool reads all of them and can list them by hue.

Other names, such as sage green, burnt orange or rose gold, have no single agreed value. Different sources give different codes, so this tool does not give one. Pantone, RAL, NCS and paint colours belong to their makers. Their tables are licensed and are not part of this tool.

Limits you should know

  • Results describe 8-bit sRGB colours. A value typed with decimals is rounded to the nearest of the 256 steps, and a half goes up.
  • lab(), lch(), oklab() and oklch() can name colours that sRGB cannot show. The tool says so and clips each channel to the range 0 to 255. Clipping changes the colour.
  • CMYK is the naive formula. It is not a print conversion and no match to a print standard is claimed.
  • The CSS color() function, colour profiles, and spot colour systems are not read.
  • Colour temperature uses published approximations for a black body from 1667 K to 25000 K. It gives the colour of the light, not a camera white balance.
  • Your typed values are worked out in this browser. They are not sent to a server.

Related tools