Color Converter

Convert a color between HEX, RGB, HSL, HSV and CMYK, in the notation CSS uses today, with alpha, all 148 named colors, a contrast check against white and black, and a palette of harmonies.

Overview

The same color can be written in many ways. #FF5733, rgb(255 87 51) and hsl(11deg 100% 60%) are three spellings of one orange: HEX and RGB give the amounts of red, green and blue light, HSL gives the hue as an angle on the color wheel with saturation and lightness. The tool reads any of them and writes all the others.

Web interface

Type a color into the input, pick one with the color picker next to it, or press one of the quick colors below. The output fields update as you type; a click on a field copies its value. The preview shows the color as text on white and on black, with the contrast ratio of each. The palette at the bottom shows harmonies of the current color; a click on one of them converts it.

The dice in the input loads a random example, in one of the notations the input takes. Clear empties everything.

What the input takes

The input reads colors as a browser reads them in a stylesheet, following CSS Color 4. Each conversion was checked against the browser's own parser in Chrome, Safari's engine and Firefox.

NotationExamples
HEX, with or without ##F53, #FF5733, and with alpha #F538, #FF573380
rgb(), rgba()rgb(255, 87, 51), rgb(255 87 51 / 50%), rgb(100%, 34%, 20%), rgba(255, 87, 51, 0.5)
hsl(), hsla()hsl(11, 100%, 60%), hsl(11deg 100% 60% / 0.5), hsl(0.5turn 60% 45%)
namesall 148 CSS named colors, in any case, and transparent

Channels outside their range are clamped, as in CSS: rgb(300, -5, 128) is rgb(255, 0, 128). A hue is taken around the circle and may be given in deg, turn, rad or grad: hsl(400, 50%, 50%) is the same color as hsl(40, 50%, 50%), and -30 is 330. Anything else is not a color; the hint above the input says so, and every output field is emptied, so nothing keeps describing the color before.

Output formats

FieldWritten as
HEX#ff5733, with alpha #ff573380
RGBrgb(255, 87, 51), with alpha rgba(255, 87, 51, 0.5)
HSLhsl(11, 100%, 60%), with alpha hsla(11, 100%, 60%, 0.5)
HSVhsv(11, 80%, 100%), as graphics programs show it
CMYKcmyk(0%, 66%, 80%, 0%)
CSS Namethe name, if the color has one

HSV and CMYK describe the color itself and carry no alpha. HSL and HSV are rounded to whole numbers, so converting them back can differ from the input by one step in a channel.

CMYK comes from the simple formula. A print shop converts with a color profile for its paper and inks, so the values it uses will differ; for print, ask for the profile.

Some colors have two names: aqua and cyan, fuchsia and magenta, and each gray also as grey. A typed name is kept as typed; otherwise the first of the two is shown. A color with alpha has no name, except transparent.

Contrast check

The preview gives the contrast ratio of the color as text on white and on black, as WCAG 2 defines it, with its level:

RatioLevel
7 or moreAAA
4.5 or moreAA
3 or moreAA Large, enough only for large text
below 3Fail

The ratio is cut after two decimals, not rounded, because WCAG compares the exact value: #777777 on white is 4.4776, shown as 4.47 and rated AA Large, where a rounded 4.5 would suggest it passes AA. A color with alpha is judged as it appears: blended with the background first.

Color palette

The palette turns the hue of the current color around the color wheel and keeps its saturation and lightness:

HarmonyColors
Complementarythe color and the one opposite, 180 degrees away
Analogousthe color and its neighbours 30 degrees either side
Triadicthree colors 120 degrees apart
Tetradicfour colors 90 degrees apart
Monochromaticthe same hue at five lightness levels, 15 points apart, between 10% and 90%

No API

There is no API for this tool. The conversion runs in the browser; in a stylesheet, the browser already accepts every notation in the table above.

Privacy

Nothing leaves the browser. The conversion runs on the page, nothing is stored, and a click on an output field writes to the clipboard only then.