OnlineTextLab
Esc

Color Converter

Any color format in, every other format out, with channels you can edit as exact numbers.

Colors you copied
HEX
RGB
HSL
HSV
OKLCH
CMYK
On white
On black

Runs on your device. Your files and text are not uploaded.

About Color Converter

A stylesheet has tomato, a design file has a hex code and a component library wants hsl(). Type whichever you have into one box and the other notations appear beside it. Accepted input includes CSS names, 3, 4, 6 and 8 digit hex, and rgb() and hsl() with either comma or space syntax.

This page leans toward working with numbers. Drag in the square to get close if you like, then edit red, green and blue, or hue, saturation and lightness, as exact values, and watch the rest follow. That suits nudging a known color by a set amount, such as taking lightness down 10 points for a hover state, and then seeing whether text on it still passes contrast.

How it works

Hex and functional notation are parsed on this page. Named colors go through the browser itself: the name is assigned to a hidden canvas context, and the page reads back the color the browser resolved, so any name your browser knows will work. All formats then come from a single red, green and blue value using the standard conversion formulas, rounded to whole numbers for display. The OKLCH row is calculated from that same value through the OKLab equations.

That rounding is worth knowing about. hsl(243, 75%, 59%) becomes #5048E5, while the hex code that displays as that same HSL is #4F46E5. Whole-number HSL has fewer possible values than 8-bit RGB, so a trip through it can move a channel slightly. The On white and On black rows use the WCAG 2 contrast formula and tell you whether the color passes AA or AAA for text.

How to use Color Converter

  1. Type a value into Any color, or drag in the square and move Hue and Opacity to choose one by eye.
  2. Or edit the numbers directly: Red, Green and Blue, or Hue, Saturation and Lightness.
  3. Read the HEX, RGB, HSL, HSV, OKLCH and CMYK rows, then press Copy beside the one you need. The color lands under Colors you copied.
  4. Check On white and On black to see how the color works with text.

One color in every row

Input
#4F46E5
Output
HEX:  #4F46E5
RGB:  rgb(79, 70, 229)
HSL:  hsl(243, 75%, 59%)
HSV:  243, 69%, 90%
OKLCH: oklch(51.06% 0.2301 276.97)
CMYK: 66%, 69%, 0%, 10%

On white: 6.29:1  passes AA
On black: 3.34:1  large text only

With an alpha value, such as #4F46E580, the RGB and HSL rows switch to the modern form: rgb(79 70 229 / 0.5). The contrast figures ignore transparency, and the page says so.

When it helps

  • Turning a CSS color name from old code into the hex value your design tokens use
  • Shifting a color's lightness by an exact number of points for a hover or focus state
  • Translating hex codes from a design file into hsl() for a stylesheet
  • Reading the alpha out of an 8-digit hex value

Tips for a better result

  • Keep your source of truth in hex or RGB. Converting through whole-number HSL and back can shift a channel by a step or two.
  • To lighten or darken a color, change only Lightness, which keeps hue the same.
  • For a full text and background pair, use the Color Contrast Checker, since the rows here only compare with pure white and pure black.

Good to know

  • It works in sRGB. It reads no oklch(), lab() or color() values, and it gives OKLCH only as output.
  • CMYK uses the plain mathematical formula, with no ink or paper profile, so treat it as a starting point for print.
  • HSV is shown as bare numbers, since CSS has no hsv() function.
  • The channel boxes hold whole numbers only. Editing them leaves the opacity where it was.
  • Colors you copied stays in this browser. The list is the same one the Color Picker shows, and it does not follow you to another device.

Questions people ask

Why doesn't my HSL value convert back to the same hex?

HSL here is rounded to whole numbers, which cannot represent every 8-bit color. The difference is usually one or two steps per channel, and too small to see.

Should I use this or the color picker?

They can do the same things, so choose by habit. This page labels each contrast result and lays its values out as rows to convert from, and the Color Picker opens with the square as the main view.

What does large text only mean?

The ratio is between 3:1 and 4.5:1. WCAG allows that for large text, roughly 18 point or 14 point bold, but not for body text.

Can I enter a color with transparency?

Yes, as 4 or 8 digit hex or with an alpha value in rgb() or hsl(). The result keeps it in the HEX, RGB and HSL rows, and the message under the box shows its value.

What to use next

Last reviewed . Read our editorial policy.