Color Converter/ HEX · RGB · HSL · HSV · CMYK

Convert between HEX, RGB, HSL, HSV, and CMYK color formats — with a live color picker and shade palette.

HEX
Shades
HEX
#3b82f6
RGB
rgb(59, 130, 246)
HSL
hsl(217, 91%, 60%)
HSV
hsv(217, 76%, 96%)
CMYK
cmyk(76%, 47%, 0%, 4%)

Did this tool solve your problem?

Code Examples

CSS / Tailwind
/* CSS custom properties */
:root {
  --color-primary: #3b82f6;         /* HEX */
  --color-primary-rgb: 59, 130, 246; /* RGB values only */
}

/* Usage */
.button {
  background: var(--color-primary);
  color: hsl(210, 40%, 98%);        /* HSL */
  border: 1px solid rgb(59 130 246 / 30%); /* CSS 4 syntax */
}

/* Tailwind config */
// tailwind.config.js
colors: { brand: '#3b82f6' }
JavaScript
// HEX → RGB
function hexToRgb(hex) {
  const n = parseInt(hex.replace('#', ''), 16);
  return { r: (n >> 16) & 255, g: (n >> 8) & 255, b: n & 255 };
}

// RGB → HEX
function rgbToHex(r, g, b) {
  return '#' + [r, g, b]
    .map(v => v.toString(16).padStart(2, '0'))
    .join('');
}

// npm: chroma-js (full-featured)
import chroma from 'chroma-js';
chroma('#3b82f6').rgb()   // [59, 130, 246]
chroma('#3b82f6').hsl()   // [0.58, 0.89, 0.60]
chroma.scale(['white','#3b82f6']).colors(6)
Python
import colorsys

# HEX → RGB
hex_str = '#3b82f6'
rgb = tuple(int(hex_str[i:i+2], 16) for i in (1, 3, 5))
# (59, 130, 246)

# RGB → HSL (0-1 range)
r, g, b = (v / 255 for v in rgb)
h, l, s = colorsys.rgb_to_hls(r, g, b)
print(f"hsl({h*360:.0f}, {s*100:.0f}%, {l*100:.0f}%)")

# pip install colour-science
import colour
colour.sRGB_to_XYZ([0.23, 0.51, 0.96])
Swift / iOS
import SwiftUI

// HEX to Color
extension Color {
  init(hex: String) {
    let hex = hex.trimmingCharacters(
      in: .alphanumerics.inverted)
    var int = UInt64()
    Scanner(string: hex).scanHexInt64(&int)
    let r = Double((int >> 16) & 0xFF) / 255
    let g = Double((int >> 8)  & 0xFF) / 255
    let b = Double( int        & 0xFF) / 255
    self.init(red: r, green: g, blue: b)
  }
}

Color(hex: "#3b82f6")

Frequently Asked Questions

What's the difference between HEX, RGB, and HSL?
HEX (hexadecimal) is the most common web format — e.g., #FF5733 — and is essentially RGB in base-16. RGB specifies red, green, and blue channel intensities (0–255). HSL uses Hue, Saturation, and Lightness, which is more intuitive for adjusting colors since you can change brightness or saturation independently.
What's the difference between HSV and HSL?
Both HSV (Hue, Saturation, Value) and HSL (Hue, Saturation, Lightness) are human-friendly color models. Key difference: In HSV, V=100% is the purest, brightest hue. In HSL, L=50% gives the purest hue — L=100% is white, L=0% is black. Photoshop and Figma typically use HSB (≈ HSV); CSS uses HSL.
What is CMYK and why doesn't the web use it?
CMYK (Cyan, Magenta, Yellow, Key/Black) is the print industry's color model, based on subtractive mixing of ink. Web and screens use additive RGB (mixing light). CSS doesn't natively support CMYK — designers typically convert from RGB to CMYK before sending files to a print shop.
How do I use HEX colors in CSS?
CSS accepts: 6-digit #RRGGBB (e.g., #3b82f6), 3-digit shorthand #RGB (e.g., #38f = #3388ff), and 8-digit #RRGGBBAA for alpha (e.g., #3b82f680 = 50% opacity). Modern browsers also support the CSS Color Level 4 color(srgb ...) syntax.
How is color contrast calculated?
WCAG recommends a contrast ratio of at least 4.5:1 (AA) or 7:1 (AAA) for body text against background. Contrast is calculated using relative luminance: linearize the RGB values, then compute (L1 + 0.05) / (L2 + 0.05) where L1 is the lighter color's luminance.
How are color shades generated?
The shade palette keeps the original Hue (H) and Saturation (S) fixed while stepping the Lightness (L) across 6 values (90% to 15%). This mirrors how Tailwind CSS generates its color palettes — useful for quickly building a brand color scale.