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
How to use the Color Code Converter
- 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.
- Read the results in the format cards. The swatch shows the color and the detected input format.
- Edit any card to convert from that format instead, for example type CMYK percentages into the CMYK field.
- Adjust opacity with the slider if you need an RGBA or 8-digit HEX value.
- 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:
| Format | Example | Range of each value | Used in |
|---|---|---|---|
| HEX | #2F6B4F | 00–FF per channel (8-digit form adds alpha) | HTML, CSS, design tools |
| RGB / RGBA | rgb(47, 107, 79) | 0–255, alpha 0–1 | CSS, screens, code |
| HSL | hsl(152, 39%, 30.2%) | hue 0–360°, S and L 0–100% | CSS, theming |
| HSV / HSB | hsv(152, 56.1%, 42%) | hue 0–360°, S and V 0–100% | Photoshop, Figma, pickers |
| CMYK | cmyk(56.1%, 0%, 26.2%, 58%) | 0–100% ink | Print estimates |
| CIE LAB | lab(40.65% -25.91 9.58) | L 0–100, a and b about −128 to 127 | Color science, CSS Color 4 |
| CIE LCH | lch(40.65% 27.63 159.71) | L 0–100, C 0–150, hue 0–360° | CSS Color 4 |
| OKLCH | oklch(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.