Web Tools • Core Flagship Pillar

Color Converter

Convert synchronously between HEX, RGB, HSL, and CMYK color spaces with live visual swatches, complementary color harmonies, and WCAG 2.1 text contrast accessibility ratios.

|
Last Updated: September 2026
|
W3C CSS Color Module Level 4 & WCAG 2.1 Verified
Quick-Select Curated Web Palettes Standard Benchmarks

Synchronous Color Models

RGB (Red, Green, Blue) rgb(59, 130, 246)
HSL (Hue, Saturation, Lightness) hsl(217, 91%, 60%)
CMYK Print Model: cmyk(76%, 47%, 0%, 4%)
#3B82F6 White Text Contrast: 4.6:1 (WCAG AA Pass)
Contrast on White
4.62 : 1
AA Normal Pass
Contrast on Black
4.54 : 1
AA Normal Pass
Complementary Harmony Color
#F6AF3B 180° Inverted Hue
#

Step-by-Step RGB to HSL & CMYK Mathematical Transformation Proof

Direct Answer & Overview
Verified Educational Guide

How to Convert Between HEX, RGB and HSL

To convert #3B82F6: 1. Split hex into pairs: R=3B₁₆=59, G=82₁₆=130, B=F6₁₆=246. 2. Normalize to [0, 1]: R'=0.231, G'=0.510, B'=0.965. 3. Lightness: L=(max+min)/2=59.8% (~60%). 4. Saturation: S=(max-min)/(2-max-min)=91.1% (~91%). 5. Hue: H=217°.

Primary Mathematical Formula Standard Mathematical Model
Standard Equation
ƒ(x)
Q.E.D.
RGB=(59,130,246)  ⟺  HEX: #3B82F6  ⟺  HSL: hsl(217∘,91%,60%)\text{RGB} = (59, 130, 246) \iff \text{HEX: } \#3\text{B}82\text{F}6 \iff \text{HSL: } \text{hsl}(217^{\circ}, 91\%, 60\%)
Evaluated with exact mathematical formulation • Rigorously verified
Exact Formula
Input Parameters
Required
1
Any valid HEX string (#3B82F6), RGB values (0–255), or HSL coordinates
Expected Outputs
Calculated
Synchronous HEX, RGB, HSL, CMYK code tokens, live swatch preview
WCAG 2.1 text contrast ratios against white and black backgrounds
Worked Numerical Example
Instant Verification
Convert HEX color #10B981 to RGB and HSL
→ R = 10₁₆ = 16; G = B9₁₆ = 185; B = 81₁₆ = 129; H = 160°; S = 84%; L = 39%
RGB: rgb(16, 185, 129) | HSL: hsl(160, 84%, 39%) | CMYK: cmyk(91%, 0%, 30%, 27%)

Digital Color Models: HEX, RGB, HSL & CMYK

Modern digital media relies on multiple complementary coordinate systems to specify and render color across electronic screens and physical print substrates:

HEX (#RRGGBB) Base-16 Encoding

Compact web and CSS markup

RGB (0–255) Additive Channels

Raw monitor pixel phosphors

HSL (H°, S%, L%) Cylindrical Space

Intuitive for UI design systems

CMYK (0–100%) Subtractive Inks

Physical 4-color offset printing

WCAG 2.1 Web Accessibility Contrast Criteria

Compliance Level Normal Text (< 18pt) Large Text (≥ 18pt or Bold 14pt) UI Components / Icons
WCAG Level AA4.5 : 1 Minimum3.0 : 1 Minimum3.0 : 1 Minimum
WCAG Level AAA7.0 : 1 Enhanced4.5 : 1 Enhanced4.5 : 1 Enhanced

Real-World Applications of Digital Color Conversions

Tailwind & CSS Design Tokens

Modern design systems use HSL or OKLCH to generate dynamic hover states and accessible dark-mode color variants.

Brand Identity Guidelines

Corporate style guides specify exact RGB values for web properties and matching CMYK ink percentages for business cards.

Accessibility Auditing

Frontend teams compute relative luminance mathematically to ensure digital applications pass Section 508 and ADA audits.

Step-by-Step Worked Numerical Solutions

Example 1: Converting Tailwind Emerald #10B981 #10B981

Problem: Convert #10B981 to RGB and CMYK.

1. R = 10₁₆ = (1×16) + 0 = 16.
2. G = B9₁₆ = (11×16) + 9 = 185.
3. B = 81₁₆ = (8×16) + 1 = 129.
4. RGB Result: rgb(16, 185, 129).
5. Normalized: R'=0.063, G'=0.725, B'=0.506.
6. Black Key K = 1 − 0.725 = 0.275 (27.5%).
7. Cyan C = (1 − 0.063 − 0.275) / (1 − 0.275) = 0.913 (91%).
Result: rgb(16, 185, 129) | cmyk(91%, 0%, 30%, 28%)

Common Pitfalls & Mistakes

RGB to CMYK Gamut Clipping

Bright RGB neon greens and blues cannot be physically reproduced by standard CMYK printing inks and will print significantly darker.

Missing # Prefix in CSS HEX

In HTML and CSS, hexadecimal color strings must include the leading hash prefix (#) to parse correctly.

Ignoring Perceived Luminance

Pure blue rgb(0, 0, 255) has low perceived luminance (L=0.07), while pure green rgb(0, 255, 0) has high perceived luminance (L=0.72).

Fact-Checked & Verified • Computational Accuracy Standards
Updated August 2026 • Editorial Policy
Authored By
Sanjay Samanta

Lead Developer & Founder of Basic Math Tools. Specializes in browser-native computational algorithms and applied mathematics.

Reviewed & Verified By
Academic Review Board

Mathematics & curriculum specialists. Audited against standard algebraic and arithmetic principles.

Found an error or have an improvement suggestion? Report a calculation issue

Frequently Asked Questions

How do you convert HEX color codes to RGB values?
A HEX code (#RRGGBB) is parsed into 3 pairs of hexadecimal digits (base 16): Red = RR, Green = GG, Blue = BB. For example, #3B82F6 converts to R = 3B₁₆ = 59, G = 82₁₆ = 130, and B = F6₁₆ = 246.
What is the mathematical difference between RGB and HSL?
RGB is an additive Cartesian color cube based on red, green, and blue light channel intensities (0–255). HSL is a cylindrical coordinate representation mapping Hue (0–360° color wheel), Saturation (0–100% color purity), and Lightness (0–100% illumination).
How is CMYK calculated from RGB values for print production?
Normalize RGB to R', G', B' in [0, 1]. Black key is K = 1 − max(R', G', B'). Then Cyan C = (1 − R' − K) / (1 − K), Magenta M = (1 − G' − K) / (1 − K), and Yellow Y = (1 − B' − K) / (1 − K).
What are WCAG 2.1 contrast ratio requirements for web accessibility?
WCAG AA requires a minimum contrast ratio of 4.5:1 for normal body text and 3:1 for large text (18pt+ or bold 14pt+). WCAG AAA requires 7:1 for normal text and 4.5:1 for large text.
Why do printed colors look different from screen colors?
Monitors use additive RGB light with a wider color gamut, whereas physical printers use subtractive CMYK ink absorption with a narrower printable gamut, causing bright saturated neon colors to appear muted in print.