Home › Image Tools › Color Code Converter

Color Code Converter

Type or paste a color in any common format and see it converted to HEX, RGB, HSL, HSV, CMYK, CIE LAB, LCH and OKLCH at once. Every field is editable, so you can also start from CMYK or LAB, and a batch mode converts whole lists of colors to a CSV.

Last updated:

Detected: HEX

Batch convert a list of colors
Advertisement
Advertisement

How to use the Color Code Converter

  1. Enter a color in the top box: a HEX code, rgb(), hsl(), hsv(), cmyk(), lab(), lch(), oklch() or a name like tomato. You can also use the color picker.
  2. Read the results in the format cards. The swatch shows the color and the detected input format.
  3. Edit any card to convert from that format instead, for example type CMYK percentages into the CMYK field.
  4. Adjust opacity with the slider if you need an RGBA or 8-digit HEX value.
  5. Copy a single value, or use Copy all formats. For many colors, open Batch convert and download the CSV.

Color format cheat sheet

The same forest green, #2F6B4F, written in every format the converter supports:

FormatExampleRange of each valueUsed in
HEX#2F6B4F00–FF per channel (8-digit form adds alpha)HTML, CSS, design tools
RGB / RGBArgb(47, 107, 79)0–255, alpha 0–1CSS, screens, code
HSLhsl(152, 39%, 30.2%)hue 0–360°, S and L 0–100%CSS, theming
HSV / HSBhsv(152, 56.1%, 42%)hue 0–360°, S and V 0–100%Photoshop, Figma, pickers
CMYKcmyk(56.1%, 0%, 26.2%, 58%)0–100% inkPrint estimates
CIE LABlab(40.65% -25.91 9.58)L 0–100, a and b about −128 to 127Color science, CSS Color 4
CIE LCHlch(40.65% 27.63 159.71)L 0–100, C 0–150, hue 0–360°CSS Color 4
OKLCHoklch(47.94% 0.078 161.08)L 0–100%, C about 0–0.4, hue 0–360°Modern CSS, design systems

Values are rounded for display; the converter keeps full precision internally, so converting back and forth does not drift.

How the conversions work

  • HEX ↔ RGB is a base-16 to base-10 change for each pair of digits.
  • RGB → HSL: with R, G, B in 0–1, L = (max + min) / 2, S = (max − min) / (1 − |2L − 1|), and the hue depends on which channel is largest.
  • RGB → HSV: V = max, S = (max − min) / max, same hue as HSL.
  • RGB → CMYK: K = 1 − max(R, G, B), then C = (1 − R − K) / (1 − K) and likewise for M and Y.
  • RGB → LAB / LCH: undo the sRGB gamma curve, convert linear RGB to CIE XYZ (D65), adapt to D50 with the Bradford matrix, then apply the CIE Lab formula. LCH is LAB in polar form: C = √(a² + b²), h = atan2(b, a).
  • RGB → OKLCH: linear RGB is converted to Ottosson's LMS cone space, cube-rooted and mixed into OKLab, then turned into polar form like LCH.

Tips

  • CMYK from a screen color is an approximation. For logos and packaging ask the printer for a proof, or pick a Pantone match with HEX to Pantone.
  • Check that text stays readable on your color with the Color Contrast Checker; WCAG AA needs 4.5:1 for normal text.
  • To build a palette, keep the OKLCH hue and chroma and change only the lightness, or use the Color Shades Generator.

Frequently asked questions

How do I convert HEX to RGB?

Split the six-digit HEX code into three pairs and convert each pair from base 16 to base 10. For #2F6B4F: 2F = 2 × 16 + 15 = 47, 6B = 6 × 16 + 11 = 107 and 4F = 4 × 16 + 15 = 79, so the color is rgb(47, 107, 79). The converter does this instantly for any code, including 3-digit and 8-digit HEX.

How is RGB converted to CMYK?

The common formula first finds K = 1 − max(R, G, B) with R, G and B scaled to 0–1, then C = (1 − R − K) / (1 − K), M = (1 − G − K) / (1 − K) and Y = (1 − B − K) / (1 − K). This gives a device-independent estimate. Printers use ICC color profiles for the exact ink mix, so check important brand colors with your print shop.

What is the difference between HSL and HSV?

Both describe a color by hue and saturation, but HSL uses lightness, where 50% is the pure color and 100% is white, while HSV (also called HSB) uses value or brightness, where 100% is the pure color at full intensity. HSL is used in CSS; HSV is what Photoshop, Figma and most color pickers show.

Which white point does the LAB conversion use?

LAB and LCH values follow the CSS Color 4 definition: CIE Lab relative to the D50 white point, converted from sRGB (D65) with a Bradford chromatic adaptation. Some older tools use D65 Lab, which gives slightly different a* and b* numbers for the same color.

What is OKLCH and why use it?

OKLCH is the polar form of the OKLab color space published by Björn Ottosson in 2020. Its lightness matches how bright colors look to people much better than HSL, so palettes built by changing only L look even. All modern browsers support oklch() in CSS.

Why does my LAB or OKLCH color show a warning?

LAB, LCH and OKLCH can describe colors that a normal sRGB screen cannot show. HEX, RGB, HSL, HSV and CMYK are limited to sRGB, so the converter shows the closest displayable color for those formats by lowering the chroma while keeping lightness and hue, and tells you the original is out of gamut.

Can I convert many colors at once?

Yes. Open Batch convert a list of colors, paste one color per line in any mix of formats and press Convert list. You get a table with every format and can download it as CSV or copy it into a spreadsheet.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

Color PickerPick any color and get HEX, RGB, HSL, HSV and CMYK codes, shades and a screen eyedropper.OKLCH Color ConverterConvert HEX, RGB and HSL to OKLCH, OKLab, Lab and LCH with sRGB and P3 gamut checks.RGB to CMYK ConverterConvert RGB and HEX colors to CMYK for print, and back.Color Contrast CheckerCheck WCAG contrast ratios and find accessible text colors.ANSI Color Code GeneratorStyle terminal text with 16, 256 or RGB colors and get escape codes for bash, Python, JS and C.Photo Color MatchCopy the color grading of a reference photo onto your image (Reinhard color transfer).Screen Color PickerPick any pixel color from anywhere on your screen and copy it as HEX, RGB or HSL.Solid Color Image GeneratorMake a plain single-color or transparent image in any size, like 1920x1080, as PNG or JPG.Color Palette GeneratorGenerate beautiful color palettes and export them.HEX to RGBConvert HEX colors to RGB and other formats.RGB to HEXConvert RGB to HEX with sliders, live swatch and one-click copy.HEX to HSLConvert HEX colors to HSL and back with interactive sliders.Pantone to HEXLook up approximate HEX, RGB and CMYK values for Pantone colors.Color Name FinderFind the closest color name for any HEX or RGB color.Color Blindness SimulatorSee any image as people with protanopia, deuteranopia, tritanopia or achromatopsia see itImage Color PickerPick any pixel colour from an image and get HEX, RGB, HSL plus a paletteColor Shades GeneratorTurn one HEX color into a 50-950 scale plus tints, shades and tones, ready to export.Tailwind Color GeneratorTurn one color into a full Tailwind 50–950 shade scale and export the config or CSS.Color MixerMix two colors in sRGB, linear, OKLab or OKLCH, or blend them with Photoshop-style modes.Random Color GeneratorGenerate random HEX colors one at a time or in batches, with hue, saturation and lightness ranges.Color WheelFind complementary, triadic, analogous and other color harmonies on an interactive wheel.HTML Color CodesAll 140 HTML color names with HEX and RGB codes, plus the 216 web-safe colors. Click to copy.Color Palette from ImageExtract the main colors of any photo as HEX codes, CSS variables and a palette PNG.Replace Color in ImageClick a color in a picture and swap it for a new color or transparency, keeping the shading.CMYK to RGBConvert CMYK percentages to RGB and HEX color codes with sliders and a live preview.HSL to HEXConvert HSL and HSLA colors to HEX and RGB with sliders and a live preview.HEX to RGBAConvert HEX color codes to CSS rgba() with an opacity slider and one-click copy.RGBA to HEXConvert rgba() colors to 8-digit HEX, or flatten transparency onto any background.HEX to CMYKConvert HEX color codes to CMYK percentages for print, with a live preview.HEX to PantoneFind the 5 closest Pantone-style solid coated colors for any HEX or RGB, ranked by Delta E.Color Temperature to RGBConvert a color temperature in kelvin (1000-40000 K) to RGB and HEX with a live swatch.RAL to HEXLook up RAL Classic codes as HEX, RGB and CMYK, search by name or find the nearest RAL.RGB to HSLConvert RGB values to HSL, HSV and HWB with a live swatch and copy-ready CSS.Room Paint Color VisualizerUpload a room photo, select the walls and preview any paint color or HEX with real lighting.Photo to Pop ArtMake Warhol-style pop art from a photo: posterized color tiles in 1, 4 or 9 grids with custom palettes.White Balance CorrectorFix color casts: click a neutral gray point or use auto gray world, then fine-tune temperature and tint.CMYK to HEXConvert CMYK percentages to a HEX color code and RGB, with a live swatch and shades.Underwater Photo Color CorrectionRestore lost reds and remove the blue or green cast from underwater photos by depth.
See all 38 Color Tools →