Color Converter
Convert colors between HEX, RGB, HSL, and CMYK formats. Pick any color and get all format values.
Pick a Color
Use the color picker or enter values below
All Formats
Tip: HEX is used in web development, RGB for screens, HSL for intuitive color adjustment, and CMYK for print.
What Is Color Conversion?
Color conversion is the process of translating a single color from one representation system to another — for example, from a hexadecimal code used in CSS to the RGB triplet used in image editors, or the HSL model used for intuitive design work, or the CMYK percentages used in professional printing.
Every digital color ultimately describes the same human-visible hue, but different tools, workflows, and industries rely on different color models. A front-end developer writing Tailwind CSS needs HEX values like #3B82F6. A designer adjusting brightness in Figma reaches for HSL. A print production team at a magazine works in CMYK. Converting accurately between these formats is essential for maintaining color consistency across screens, print, and code.
This color converter accepts input in HEX, RGB, or HSL format and simultaneously outputs all six common representations: HEX, RGB, RGBA, HSL, HSLA, and CMYK. The conversion chain is: whichever format you enter is first normalized to an RGB triplet (three integers 0–255), and then all other formats are derived from that shared RGB basis using the standard mathematical formulas described below.
Color Conversion Formulas
Understanding the underlying math helps you predict conversion results and debug unexpected color shifts. All conversions in this tool pass through RGB as the common intermediate representation.
HEX ↔ RGB
A HEX color like #RRGGBB stores each channel as a two-digit base-16 number. Converting to RGB simply parses each pair: R = parseInt(RR, 16), and the same for G and B. The reverse uses value.toString(16).padStart(2, '0').toUpperCase() for each channel, clipped to [0, 255].
RGB → HSL
Normalize each channel to [0, 1] by dividing by 255. Let max = maximum of r, g, b and min = minimum. Lightness L = (max + min) / 2. If max equals min the color is achromatic (H = S = 0). Otherwise the chroma d = max − min, and:
- S = d / (2 − max − min) when L > 0.5, else d / (max + min)
- H is computed from which channel is maximum: if R is max, H = ((G − B) / d + (G < B ? 6 : 0)) / 6; if G is max, H = ((B − R) / d + 2) / 6; if B is max, H = ((R − G) / d + 4) / 6
Multiply H by 360, S and L by 100, then round.
HSL → RGB
Normalize H to [0,1], S and L to [0,1]. If S = 0, R = G = B = L (grey). Otherwise compute helper values q = L < 0.5 ? L × (1 + S) : L + S − L × S and p = 2L − q. Then use the hue2rgb(p, q, t) piecewise function (returning p + (q−p)×6×t for t < 1/6; q for t < 1/2; p + (q−p)×(2/3−t)×6 for t < 2/3; else p) applied at H+1/3 (red), H (green), H−1/3 (blue). Multiply results by 255 and round.
RGB → CMYK
Normalize to [0,1]: rr = R/255, gg = G/255, bb = B/255. Black key K = 1 − max(rr, gg, bb). If K = 1 (pure black) return C = M = Y = 0, K = 100. Otherwise:
- C = (1 − rr − K) / (1 − K)
- M = (1 − gg − K) / (1 − K)
- Y = (1 − bb − K) / (1 − K)
Multiply each by 100 and round to get percentages.
RGB → CMYK Formula
Where:
- R, G, B= Red, Green, Blue channel values (0–255)
- K= Black key component (0–1 before ×100)
- C, M, Y= Cyan, Magenta, Yellow percentages (0–100)
HEX Color Model Explained
Hexadecimal color codes are the standard notation for colors in HTML, CSS, and SVG. The format #RRGGBB uses base-16 digits (0–9, A–F) to encode each of the three RGB channels in two characters. Since each pair can represent 256 values (00–FF in hex = 0–255 in decimal), the full HEX space covers 256³ = 16,777,216 distinct colors.
A shorthand form #RGB is also valid CSS — the browser expands it by doubling each digit, so #3BF becomes #33BBFF. This converter works with the full six-character form.
HEX is preferred in web development because it is compact, human-readable once you learn common patterns, and natively supported in CSS without a function call. Color values like #FF0000 (pure red), #00FF00 (pure green), var(--foreground)0FF (pure blue), and var(--card-bg)FFF (white) are instantly recognizable to experienced developers.
One limitation of HEX is that it does not intuitively convey perceptual properties like brightness or vividness — adjusting the lightness of a HEX color requires mental conversion to HSL or direct manipulation in a design tool. That is why color pickers and design systems increasingly expose HSL controls alongside HEX outputs.
HSL: Intuitive Color for Designers
HSL (Hue, Saturation, Lightness) organizes colors in a way that matches human perception far better than RGB or HEX. Hue is an angle on the color wheel from 0° to 360° — 0° is red, 120° is green, 240° is blue. Saturation is a percentage from 0% (grey) to 100% (fully vivid). Lightness goes from 0% (black) to 100% (white), with 50% being the "pure" color.
The power of HSL for design work is that you can independently adjust individual perceptual properties. To create a lighter tint of a brand color, just increase L. To desaturate a color for a disabled button state, drop S. To shift a hue family (e.g., from blue to teal) without changing brightness, adjust H alone. None of these operations are straightforward when working in raw RGB or HEX.
Modern CSS supports HSL natively via hsl(217, 91%, 60%) and the alpha variant hsla(217, 91%, 60%, 0.5), making it a first-class option for design systems, theming, and CSS custom properties. Many CSS frameworks use HSL internally for generating color scales.
A caveat: HSL is not perceptually uniform — two colors with the same HSL lightness value can appear very different in perceived brightness to human eyes (yellow at L=50% looks much brighter than blue at L=50%). For perceptually uniform color work, professionals may prefer OKLCH or Lab color spaces, though HSL remains by far the most widely used in web development.
CMYK for Print and Professional Output
CMYK stands for Cyan, Magenta, Yellow, and Key (Black) — the four ink colors used in color printing. Unlike RGB which is an additive model (mixing light), CMYK is a subtractive model: inks absorb (subtract) portions of reflected white light. Mixing all three CMY inks in theory produces black, but in practice the result is a muddy dark brown, which is why a separate K (black) ink is used for crisp text and deep shadows.
Each CMYK component is expressed as a percentage (0–100%). A value of C=0, M=0, Y=0, K=0 represents pure white (no ink applied). C=0, M=0, Y=0, K=100 is pure black. A rich red might be C=0, M=100, Y=100, K=0.
The conversion from RGB to CMYK used in this tool is a mathematical approximation that works well for screen-to-print estimation. Professional print workflows often require device-specific ICC color profiles and specialized software (like Adobe InDesign or Photoshop) for production-accurate CMYK values, because the exact ink response varies between printing devices, paper stocks, and ink formulations. The formula here gives a solid starting point for estimating ink percentages from screen colors.
When preparing files for offset printing, brochures, business cards, or packaging, always confirm CMYK values with your print vendor and request a proof before the full print run. Colors can shift significantly between monitor and print, especially highly saturated or neon RGB colors that fall outside the CMYK gamut.
| Color Model | Use Case | Range |
|---|---|---|
| HEX | Web/CSS | var(--foreground)000 – var(--card-bg)FFF |
| RGB | Screens, image editing | 0–255 per channel |
| HSL | Design systems, CSS themes | H: 0–360°, S/L: 0–100% |
| CMYK | Print production | 0–100% per channel |
Which Color Format Should You Use?
Choosing the right color format depends on your target medium, toolchain, and workflow. Here is a practical guide to when each format is most appropriate.
Use HEX when writing HTML, CSS, or Tailwind utility classes. It is compact, universal, and directly pasteable into any browser stylesheet. Design tokens in style guides and component libraries are almost always expressed in HEX for portability.
Use RGB or RGBA when you need to manipulate color programmatically in JavaScript (e.g., canvas APIs, WebGL shaders, image processing), or when you need alpha transparency with the four-value rgba(r, g, b, a) syntax. The RGBA variant is also useful in CSS when combining a color with opacity independently of the element's transparency.
Use HSL or HSLA when building design systems or themes where you need predictable color relationships. Generating a palette of tints and shades by varying L from 10% to 90% is trivial in HSL. Theming frameworks like Radix UI, shadcn/ui, and many others use HSL custom properties as their foundation precisely because HSL is so composable.
Use CMYK when handing off assets to a print vendor, preparing InDesign or Illustrator documents for offset printing, or specifying Pantone spot colors. Digital outputs (web, mobile, TV) never actually use CMYK — it is exclusively a print concept, so do not use CMYK values in CSS or digital graphics.
Worked Examples
Convert Tailwind Blue (#3B82F6) to All Formats
Problem:
Tailwind CSS defines its blue-500 as #3B82F6. Convert this to RGB, HSL, and CMYK.
Solution Steps:
- 1Parse HEX to RGB: R = parseInt('3B', 16) = 59, G = parseInt('82', 16) = 130, B = parseInt('F6', 16) = 246
- 2RGB → HSL: normalize to r=0.231, g=0.510, b=0.965. max=0.965 (b), min=0.231 (r). L=(0.965+0.231)/2=0.598≈60%. d=0.965−0.231=0.734. Since L>0.5: S=0.734/(2−0.965−0.231)=0.734/0.804≈0.913≈91%. H=((0.231−0.510)/0.734+4)/6=(−0.380+4)/6×6×(1/6)=(3.620)/6≈0.603×360≈217°
- 3RGB → CMYK: rr=59/255=0.231, gg=130/255=0.510, bb=246/255=0.965. K=1−0.965=0.035. C=(1−0.231−0.035)/(1−0.035)×100=(0.734/0.965)×100≈76%. M=(1−0.510−0.035)/0.965×100=(0.455/0.965)×100≈47%. Y=(1−0.965−0.035)/0.965×100=0/0.965×100=0%. K=0.035×100≈4%
- 4Results: HEX #3B82F6 = rgb(59, 130, 246) = hsl(217, 91%, 60%) = cmyk(76%, 47%, 0%, 4%)
Result:
rgb(59, 130, 246) | hsl(217, 91%, 60%) | cmyk(76%, 47%, 0%, 4%)
Convert HSL(0, 100%, 50%) — Pure Red — to HEX and CMYK
Problem:
HSL(0, 100%, 50%) is the canonical pure red. Convert it to RGB, HEX, and CMYK.
Solution Steps:
- 1HSL → RGB: h=0/360=0, s=1, l=0.5. q=0.5×(1+1)=1. p=2×0.5−1=0. R=hue2rgb(0,1, 0+1/3=0.333): t=0.333>1/6 and <1/2, so returns q=1. G=hue2rgb(0,1, 0): t=0, returns p+(q−p)×6×0=0. B=hue2rgb(0,1, 0−1/3=−0.333→+1=0.667): t=0.667>2/3, returns p=0. R=1×255=255, G=0, B=0
- 2RGB → HEX: 255→FF, 0→00, 0→00 → #FF0000
- 3RGB → CMYK: rr=1, gg=0, bb=0. K=1−max(1,0,0)=0. C=(1−1−0)/(1−0)×100=0%. M=(1−0−0)/1×100=100%. Y=(1−0−0)/1×100=100%. K=0%
- 4Results: HEX #FF0000 = rgb(255, 0, 0) = cmyk(0%, 100%, 100%, 0%)
Result:
#FF0000 | rgb(255, 0, 0) | cmyk(0%, 100%, 100%, 0%)
Convert RGB(128, 128, 128) — Mid Grey — to HSL and CMYK
Problem:
A perfect mid-grey has equal R, G, and B values of 128. Verify the HSL and CMYK outputs.
Solution Steps:
- 1RGB → HSL: normalize r=g=b=128/255≈0.502. max=min=0.502, so d=0. Achromatic case: H=0, S=0. L=(0.502+0.502)/2=0.502≈50%. Result: hsl(0, 0%, 50%)
- 2RGB → CMYK: rr=gg=bb=128/255≈0.502. K=1−0.502=0.498≈50%. C=(1−0.502−0.498)/(1−0.498)×100=0/0.502×100=0%. M=0%. Y=0%. K≈50%
- 3HEX: 128 in decimal = 80 in hex → #808080
- 4Grey colors always have H=0, S=0 in HSL, and C=M=Y=0 in CMYK — only K varies with lightness.
Result:
#808080 | hsl(0, 0%, 50%) | cmyk(0%, 0%, 0%, 50%)
Convert CMYK-typical Green rgb(0, 168, 0) to All Formats
Problem:
A vivid green specified as RGB(0, 168, 0) needs converting for both web and print use.
Solution Steps:
- 1RGB → HEX: 0→00, 168→A8, 0→00 → #00A800
- 2RGB → HSL: normalize r=0, g=168/255≈0.659, b=0. max=0.659 (g), min=0. L=(0.659+0)/2=0.329≈33%. d=0.659. S=0.659/(0.659+0)=1.0→100%. H=((0−0)/0.659+2)/6=2/6=0.333×360=120°. Result: hsl(120, 100%, 33%)
- 3RGB → CMYK: rr=0, gg=0.659, bb=0. K=1−0.659=0.341≈34%. C=(1−0−0.341)/(1−0.341)×100=(0.659/0.659)×100=100%. M=(1−0.659−0.341)/0.659×100=0/0.659×100=0%. Y=(1−0−0.341)/0.659×100=0.659/0.659×100=100%... wait: Y=(1−bb−K)/(1−K)=(1−0−0.341)/0.659=0.659/0.659=1→100%. K=34%
- 4Results: #00A800 = hsl(120, 100%, 33%) = cmyk(100%, 0%, 100%, 34%)
Result:
#00A800 | hsl(120, 100%, 33%) | cmyk(100%, 0%, 100%, 34%)
Tips & Best Practices
- ✓Paste any CSS color value directly into the HEX input — the tool accepts both lowercase (#3b82f6) and uppercase (#3B82F6).
- ✓Click any output row (HEX, RGB, HSL, CMYK…) to instantly copy it to your clipboard — no selecting text needed.
- ✓Use HSL when building a color palette: keep H and S fixed, then step L in 10% increments to generate consistent tints and shades.
- ✓For print files, use the CMYK output as an estimate and always verify with a physical proof — especially for saturated blues and greens, which often fall outside the print gamut.
- ✓RGBA and HSLA outputs always have alpha=1. Copy them and change the last value (0–1) to add transparency without touching the color itself.
- ✓Equal R, G, and B values always produce a grey — and will always show S=0 in HSL and C=M=Y=0 in CMYK regardless of the brightness level.
- ✓If a CMYK K value is near 100%, the color is near black; consider using a pure black (K=100, C=M=Y=0) instead for sharper print output.
- ✓The color picker (the square swatch) always stays in sync — click it to visually browse the color wheel instead of typing values.
Frequently Asked Questions
Sources & References
Last updated: 2026-06-05
Help us improve!
How would you rate the Color Converter?
Editorial Note
MyCalcBuddy Editorial Team
This page is maintained as an educational calculator reference.
Formula Source: Standard Mathematical References
by Various