Color Converter

Convert colors bidirectionally between HEX, RGB, HSL, and CMYK formats instantly. Built entirely offline in client-side memory.

Visual Picker
Click to pick a color
Invalid HEX format (use #RRGGBB or #RGB)
Invalid RGB format (use rgb(R, G, B) or R, G, B values 0-255)
Invalid HSL format (use hsl(H, S%, L%) or H, S, L values)
Invalid CMYK format (use cmyk(C%, M%, Y%, K%) or C, M, Y, K values)
Data Serialization & Radix • Technical Reference Modern CSS Layout & Color Spaces Guide

Working with Color Converter? Read our architectural guide or browse all utilities in the Converters & Encoders Hub.

Read Guide →

Color Space Mathematics: HEX, RGB, HSL & CMYK

A color space is a mathematical model describing the way colors can be represented as tuples of numbers. In graphic design, UI engineering, and print production, working across multiple digital and physical media requires continuous conversion between additive and subtractive color spaces.

The primary color spaces supported in modern design include:

Our Color Converter translates colors across all spaces simultaneously, calculating WCAG contrast ratios and one-click CSS code copies.

Programmatic Color Space Conversion in JavaScript

// Convert HEX to RGB
function hexToRgb(hex) {
  const cleanHex = hex.replace(/^#/, '');
  const num = parseInt(cleanHex, 16);
  return {
    r: (num >> 16) & 255,
    g: (num >> 8) & 255,
    b: num & 255
  };
}

// Convert RGB to HSL
function rgbToHsl(r, g, b) {
  r /= 255; g /= 255; b /= 255;
  const max = Math.max(r, g, b), min = Math.min(r, g, b);
  let h, s, l = (max + min) / 2;

  if (max === min) {
    h = s = 0; // achromatic
  } else {
    const d = max - min;
    s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
    switch (max) {
      case r: h = (g - b) / d + (g < b ? 6 : 0); break;
      case g: h = (b - r) / d + 2; break;
      case b: h = (r - g) / d + 4; break;
    }
    h /= 6;
  }
  return { h: Math.round(h * 360), s: Math.round(s * 100), l: Math.round(l * 100) };
}

console.log(hexToRgb("#6366F1")); // { r: 99, g: 102, b: 241 }
console.log(rgbToHsl(99, 102, 241)); // { h: 239, s: 84, l: 67 }

WCAG 2.1 Color Contrast & Accessibility Standards

Web Content Accessibility Guidelines (WCAG) 2.1 establish strict minimum color contrast ratios between text and background to ensure readability for users with low vision or color blindness:

Next-Gen CSS Color Spaces: OKLCH & Display P3

CSS Color Module Level 4 introduces modern perceptual spaces like OKLCH and Display P3. OKLCH fixes long-standing visual luminance bugs in HSL, ensuring that colors with identical lightness values appear equally bright to human eyes across all hues.

Related Converters & Encoders

Chain Color Converter with these complementary client-side utilities from our Converters & Encoders collection:

HTML to Markdown Converter →

Convert HTML code snippets to clean Markdown syntax instantly. Free online client-side tool. Includes support for lists, tables, headers, and code blocks.

Roman Numeral Converter →

Free online Roman Numeral converter. Instantly translate numbers to Roman numerals and Roman numerals to numbers (1-3999) offline. Private and secure.

URL Encoder & Decoder →

Encode URL query parameters or decode percent-escaped URLs into readable strings instantly. 100% private, client-side, and supports safe query encoding.

Base64 Encoder & Decoder →

Convert plain text to Base64 format or decode Base64 strings to readable text instantly. 100% private, browser-based, and supports UTF-8.

Frequently Asked Questions

RGB is an emissive light model with a wide gamut of bright neon colors. CMYK is a reflective ink model with a narrower physical color gamut; some vivid RGB colors cannot be physically reproduced with printing inks.

The alpha channel specifies opacity, ranging from 0.0 (completely transparent) to 1.0 (completely opaque).

With HSL, keep the Hue and Saturation identical, and simply reduce the Lightness percentage by 10% to 15% (e.g. hsl(240, 80%, 50%) becomes hsl(240, 80%, 40%)).

Yes. Shorthand hex codes are automatically expanded to full 6-digit representations (#ffffff).

Yes. All transformations are computed locally using client-side JavaScript.