Skip to main content
CC

Color Converter

Bidirectional color converter — HEX, RGB, HSL, HSV, CMYK, plus a native color picker, all updating live as you type.

Did you like the tool? Thanks!
Share:
H: S: L:
H: S: V:
C: M: Y: K:

How to Use Color Converter

Pick a color with the native color picker, or type a value into any format field — HEX, RGB (three sliders or number inputs), HSL, HSV, or CMYK — and every other format recalculates instantly on every keystroke. Each format has its own Copy button so you can grab just the string you need without manual reformatting. Invalid hex codes show an inline error instead of silently producing wrong results; RGB values are clamped to 0-255, HSL and HSV hue to 0-360, and percentages to 0-100.

About Color Converter

Different tools, libraries, and platforms expect colours in different formats. CSS uses hex (e.g. `#1e90ff`) for most declarations; design tools and colour-picker extensions often give you HSL so you can reason about hue independently of saturation and lightness; image-editing and print workflows live in CMYK; and the HSV model (also called HSB) is the one most commonly exposed by native operating-system colour pickers and by graphic-software sliders because it maps naturally onto the idea of starting with a pure hue and then darkening or desaturating it. Needing to mentally convert between these by hand — or worse, opening a separate conversion website for every single colour — is a friction that this tool eliminates by keeping all six views in sync on a single screen. The conversion chain is entirely RGB-based internally. Whichever format you type into is parsed to a normalised RGB triple (each channel a decimal between 0 and 255), rounding and clamping at the boundaries, and then every other format is recalculated from that single source of truth. This means that even exotic round-trip paths — type into CMYK, read the result in HSV — produce the same answer as converting through hex or through RGB directly, because they all bottom out on the same three numbers. The HSL-to-RGB and HSV-to-RGB formulas use the standard geometric transforms; the RGB-to-CMYK formulas use the subtraction-from-1 definition with the usual K-minimisation shortcut. The native `<input type="color">` always emits a hex string, so the picker feeds into the same hex parser as typing `#` followed by six characters.

Details & Tips

Formulas used and their origin: **RGB to HSL:** The RGB channels are first normalised to the range 0-1 (dividing each by 255). The min and max of the three channels give the overall intensity range. Lightness L = (max + min) / 2. Saturation is 0 if max and min are equal; otherwise, S = (max - min) / (1 - |2L - 1|). Hue is computed as a fraction of a full circle (then multiplied by 360 for degrees): if max is red, hue = (G - B) / (max - min) mod 6; if max is green, hue = (B - R) / (max - min) + 2; if max is blue, hue = (R - G) / (max - min) + 4. Negative hue values are wrapped by adding 360. **RGB to HSV:** V = max (the largest channel). S = (max - min) / max when max is non-zero, else 0. Hue is computed exactly as for HSL — the geometric definition of "hue" is the same in both cylindrical models; they only differ in how they map saturation and the lightness/value axis. **RGB to CMYK:** Each channel is scaled to R' = R/255, G' = G/255, B' = B/255. The black key K = 1 - max(R', G', B'). If K = 1 (pure black), C = M = Y = 0. Otherwise, C = (1 - R' - K) / (1 - K), M = (1 - G' - K) / (1 - K), Y = (1 - B' - K) / (1 - K). The three results are multiplied by 100 and rounded to integers for display. **HSL to RGB:** The lightness L is normalised to 0-1. If saturation S is 0, all three channels equal L. Otherwise, temporary values t1 and t2 are computed: if L < 0.5, t2 = L * (1 + S); else t2 = L + S - (L * S). t1 = 2 * L - t2. The hue H is normalised to a 0-1 fraction by dividing by 360, and the three channels are computed by a helper that returns t1 if the cubic helper is < 1/6, t2 if < 1/2, t1 if < 2/3, or t1 otherwise, with wraparound by adding/subtracting 1. **Clamping behaviour:** RGB inputs are clamped to the integer range 0-255 (typing 300 automatically becomes 255). HSL hue wraps: any value modulo 360, so 370 becomes 10. HSL/HSV saturation, lightness, and value are clamped to 0-100. CMYK channels are clamped to 0-100. Entering an incomplete or malformed hex code (fewer than 3 or 6 hex digits, or characters other than 0-9 a-f) sets an error message and leaves the other formats unchanged from their last valid state — the tool never silently corrupts all formats because of one bad keystroke. **Colour picker integration:** The native `<input type="color">` emits a 7-character hex string (`#rrggbb`) on change. Picking a colour from the OS palette updates the hex field and recomputes all other formats. Conversely, typing into any numeric field programmatically updates the picker's `.value` property via Alpine's `x-model` binding, so the two-way sync is always visible. **Copy behaviour:** Each format section has its own Copy button. The copied string is format-specific: for hex it copies `#1e90ff`; for RGB it copies `rgb(30, 144, 255)`; for HSL it copies `hsl(210, 100%, 56%)`; for HSV it copies `hsv(210, 88%, 100%)`; for CMYK it copies `cmyk(88%, 44%, 0%, 0%)`. This means you can paste the value directly into CSS, a design-file text field, or a print-spec document without needing to reformat by hand.

Frequently Asked Questions

How do I use the color converter?
Type a value into any format field — hex, RGB, HSL, HSV, or CMYK — or use the native colour picker. All other formats recalculate instantly on every keystroke.
What colour formats does this tool support?
HEX (6-digit, e.g. #1e90ff), RGB (three numbers 0-255), HSL (hue 0-360, saturation and lightness 0-100%), HSV (hue 0-360, saturation and value 0-100%), and CMYK (cyan, magenta, yellow, and key 0-100%).
What happens if I type an invalid hex code?
An error message appears below the hex field and no other formats are updated until you correct the input. The tool never silently produces wrong results from a bad hex value.
What happens if I type an RGB value larger than 255 or smaller than 0?
Values are automatically clamped — typing 300 becomes 255, and negative values become 0. This prevents impossible colours from being fed into the conversion formulas.
Can I copy individual format strings?
Yes, each format section (HEX, RGB, HSL, HSV, CMYK) has its own Copy button that copies the exact string in the standard format for that colour model.
Does the HSL hue wrap around beyond 360?
Yes — typing 370 wraps to 10 degrees, and negative hues are wrapped by adding 360, because hue is conceptually a circular value.
Are the conversion formulas accurate?
The tool uses the standard mathematical formulas for each conversion: the geometric hue definition common to HSL and HSV, the cylindrical lightness and value calculations, and the subtraction-from-1 CMYK formula. Results may differ by one unit from some reference implementations due to rounding.
What is the difference between HSL and HSV?
Both models share the same hue definition. HSL uses Lightness — pure white is always at L=100%, pure black at L=0%. HSV uses Value — white is any colour at S=0% with V=100%, while the bottom of the cylinder is always black. Designers often find HSL more intuitive for colour picking, while HSV is closer to how pigments mix.
Does the CMYK conversion match print-process results exactly?
No — the formula used is the mathematical one based on RGB subtraction, which gives theoretical CMYK values. Real print presses use ICC colour profiles, dot gain, and ink-specific behaviour that cannot be predicted without a profile. Use this as a starting point, not a final press-ready separation.
Can I use the native OS colour picker?
Yes — the colour swatch at the top opens your operating system's native colour picker. Selecting a colour there updates every format field instantly.
Is any data sent to a server?
No — all colour conversions run locally in your browser using JavaScript. Nothing you type is transmitted anywhere.
Why does the hex field show an error for 3-digit shorthand like #abc?
The tool expects 6-digit hex codes. Shorthand 3-digit hex is valid CSS but is expanded by doubling each digit (#abc → #aabbcc). You can type the expanded form directly if the shorthand is needed.

Part of These Collections

Also Available As

color converter, hex to rgb, rgb to hsl, hsl to hex, color picker, rgb to cmyk, hex to cmyk, hsl to rgb, hsv converter, cmyk converter, bidirectional color converter

Found a Problem?

Let us know if something with Color Converter isn't working as expected.

Thanks — we'll take a look.