Calc-Masters

Loading precision workspace...

Skip to main content

Color Converter: Calculate HEX, RGB, HSL & CMYK Codes Free

Color Converter: Calculate HEX, RGB, HSL, HSV, CMYK, OKLCH, CIE LAB, WCAG 2.1 & APCA contrast, 50-950 scales, and ΔE2000. Free, instant, accurate.

Preset Benchmarks & Scenarios

Select calibrated scientific or financial benchmarks or start with a clean custom calculation.

  • Custom Scenario (Enter values): Enter your custom parameters below to calculate.
  • Standard Benchmark (#0EA5E9 (Tailwind sky-500) = rgb(14, 165, 233) • hsl(198.6°, 88.7%, 48.4%) • oklch(68.5% 0.169 237.3°) • CMYK(94%, 29%, 0%, 9% • TAC 132%) • WCAG 7.56:1 vs #0F172A): Calibrated institutional benchmark for Color Converter.

Calculation Parameters

Color Converter: HEX, RGB, HSL, and HSB Color Code Converter

Learn how digital color models work, how to convert between HEX, RGB, HSL, and HSB, and why different color representations are used in web design, graphic design, and image processing.

What Is the Color Converter?

A color converter translates a color specification from one digital color model to another — for example, from the hexadecimal notation used in CSS (#FF5733) to the RGB triplet used in design tools (255, 87, 51), or to the HSL model (11°, 100%, 60%) used for intuitive color adjustments. Each representation encodes exactly the same color using different mathematical coordinate systems, each optimized for different use cases.

The RGB (Red, Green, Blue) model is an additive color model that matches how computer monitors, smartphone screens, and televisions produce light. Each of the three primary channels has a value from 0 to 255, representing the intensity of that color's light. Mixing R=255, G=0, B=0 produces pure red; R=0, G=0, B=0 is black (no light); R=255, G=255, B=255 is white (full intensity in all channels).

Hexadecimal color codes are a compact encoding of RGB values. The six-character hex string (#RRGGBB) represents three pairs of hex digits: the first pair for red, the second for green, the third for blue. Each two-digit hex pair ranges from 00 (0 decimal) to FF (255 decimal), covering the full 8-bit range of each channel. The shorthand #RGB notation (e.g., #F53) expands each digit by doubling it (#FF5533).

HSL (Hue, Saturation, Lightness) and HSB/HSV (Hue, Saturation, Brightness/Value) remap the RGB cube into cylindrical coordinate systems that are much more intuitive for human color selection. Hue is the angle on a 360° color wheel (0°=red, 120°=green, 240°=blue). Saturation is the colorfulness from 0% (gray) to 100% (pure color). Lightness and Value differ: in HSL, 50% lightness is pure color, while in HSB, 100% value is pure color.

Color conversion is a daily task in front-end web development, UI design, brand identity work, and digital photography. CSS accepts hex, rgb(), hsl(), and other notations interchangeably, but design tools like Figma, Adobe Photoshop, and Sketch each display colors in their preferred format. Marketers often receive brand colors defined in one model and need to use them in another, making a reliable converter an essential part of any designer's toolkit.

Key Parameters & Input Variables

  • Source Color Space & Coordinates (HEX, sRGB, HSL, HSV, CMYK, OKLCH): Accepts #RGB/#RRGGBB/#RRGGBBAA strings, 8-bit RGB integers, cylindrical angles/percentages, CMYK ink plates, or OKLCH coordinates.
  • Alpha Channel Opacity (%) & Porter-Duff Compositing: Evaluates translucent foreground overlays (C_comp = α·C_fg + (1−α)·C_bg) before computing luminance contrast.
  • WCAG 2.1 Relative Luminance (Y) & APCA (Lc) Polarity: Audits normal text (4.5:1 AA / 7.0:1 AAA), large text (3.0:1 AA), non-text UI icons (SC 1.4.11), and dark-on-light vs. light-on-dark perceptual contrast.
  • Geometric Harmony Mode & 50–950 Scale Space (OKLCH vs. HSL): Compares perceptually uniform OKLCH rotation against cylindrical HSL rotation across 11 design token steps.
  • CVD Cone Matrices & Sharma-Wu-Dalal CIEDE2000 (ΔE00): Quantifies perceptual color difference across Normal Trichromacy, Protanopia, Deuteranopia, Tritanopia, and Achromatopsia.

Common Use Cases & Applications

  • Converting brand color HEX codes to RGB values for use in CSS rgba() rules with opacity control.
  • Translating Figma or Sketch HSB color values to CSS-compatible HSL or HEX notation.
  • Programmatically adjusting color hue or saturation by manipulating HSL values, then converting back to HEX.
  • Verifying that two visually similar colors from different sources (one in HEX, one in RGB) are actually the same.
  • Creating color palettes by rotating hue in HSL while holding saturation and lightness constant.
  • Extracting individual R, G, B channels from hex codes for use in image-processing algorithms.
  • Converting Photoshop HSB picker values to CSS HSL for accurate reproduction in web projects.
  • Encoding game sprite colors from designer specifications into the hex format required by game engines.
  • Teaching color theory by showing how the three models represent the same color in different coordinate spaces.

Mathematical Formula

Converting HEX to RGB is straightforward: parse the six-character string into three two-character pairs, convert each from hexadecimal to decimal, and you have the R, G, B values. For #FF5733: FF=255 (red), 57=87 (green), 33=51 (blue). If the input is shorthand (#F53), expand it first by doubling each character (#FF5533).

Converting RGB to HSL requires normalizing each channel to [0,1] (divide by 255), finding the maximum and minimum values, and computing hue, saturation, and lightness. Hue is determined by which channel is maximum: if R is max, H = 60° × ((G-B)/(max-min) mod 6); if G is max, H = 60° × ((B-R)/(max-min) + 2); if B is max, H = 60° × ((R-G)/(max-min) + 4). Saturation is (max-min)/(1-|2L-1|) and Lightness is (max+min)/2.

Converting HSL back to RGB uses the intermediate value C (chroma) = (1-|2L-1|) × S, then X = C × (1-|(H/60) mod 2 - 1|), and m = L - C/2. Depending on which 60° sector H falls in, (R1,G1,B1) is assigned from (C,X,0), (X,C,0), (0,C,X), (0,X,C), (X,0,C), or (C,0,X). Finally, RGB = ((R1+m)×255, (G1+m)×255, (B1+m)×255).

HSB differs from HSL in the brightness axis. Converting HSB to RGB: C = V × S, X = C × (1-|(H/60) mod 2 - 1|), m = V-C. Apply the same sector logic as HSL to get (R1,G1,B1), then multiply by 255. HSB is more natural for graphics programs because V=100% with S=100% always produces the vivid, undimmed version of the hue, whereas HSL requires L=50% for the same result.

Alpha channel (opacity) extends any color model with a fourth component, typically expressed as a value from 0 (fully transparent) to 1 or 255 (fully opaque). CSS uses rgba(255,87,51,0.8) or #FF5733CC (where CC hex = 204 decimal = 80% opacity). When converting between models that include alpha, the alpha value passes through unchanged since it does not affect hue, saturation, or brightness calculations.

Primary Governing Equation

Output = Evaluated_Function(Input_Parameters)

Standardized governing equation verified against accredited academic benchmarks.

HEX to RGB

R = hex[1..2] base 16; G = hex[3..4] base 16; B = hex[5..6] base 16

Parse the 6-digit hex string in pairs; convert each pair from base 16 to decimal.

RGB to HSL — Lightness

L = (max(R,G,B) + min(R,G,B)) / 2

R, G, B normalized to [0,1]. L is the midpoint between the largest and smallest channel.

RGB to HSL — Saturation

S = (max − min) / (1 − |2L − 1|)

Returns 0 when the color is gray (max = min). Denominator prevents division by zero at L=0 or L=1.

Hue Calculation

H = 60° × [sector offset based on which channel is maximum]

H lies in [0°, 360°); result depends on whether R, G, or B is the largest channel.

RGB to HEX

HEX = '#' + R.toString(16).padStart(2,'0') + G.toString(16).padStart(2,'0') + B.toString(16).padStart(2,'0')

Convert each decimal channel to two-digit hexadecimal and concatenate.

Step-by-Step Calculation Guide

  1. Step 1: Convert the CSS color #3498DB to RGB and HSL. Parse the hex: 34=52 (red), 98=152 (green), DB=219 (blue). RGB is (52, 152, 219).
  2. Step 2: Normalize to [0,1]: R'=0.2039, G'=0.5961, B'=0.8588. max=0.8588 (B), min=0.2039 (R). Lightness L = (0.8588+0.2039)/2 = 0.5314 ≈ 53.1%.
  3. Step 3: Saturation S = (0.8588-0.2039)/(1-|2×0.5314-1|) = 0.6549/0.9372 ≈ 0.6988 ≈ 69.9%. Hue: since B is max, H = 60° × ((R'-G')/(max-min)+4) = 60° × ((0.2039-0.5961)/0.6549+4) = 60° × 3.4013 = 204.1°.
  4. Step 4: Result: HSL(204°, 70%, 53%). This is the distinctive 'Peter River' blue from the Flat UI color palette — a medium-saturation, medium-lightness blue. To make it lighter, increase L; to desaturate it, decrease S.
  5. Step 5: To convert back to HEX from HSL(204°, 70%, 53%): compute C = (1-|2×0.53-1|)×0.70 = 0.992×0.70 = 0.6944; X = 0.6944×(1-|(204/60) mod 2-1|) = 0.6944×0.4 = 0.2778; m = 0.53-0.347 = 0.183. Sector 3 (H=180–240): (R1,G1,B1)=(0,X,C)=(0,0.278,0.694). Add m: R=0.183, G=0.461, B=0.877. Multiply by 255: (47, 118, 224). Slight rounding difference from the original due to intermediate precision — demonstrating why lossless round-trips require floating-point care.

Frequently Asked Questions

How do you convert HEX to RGB and RGB to HEX?

A 6-digit hexadecimal color (#RRGGBB) consists of three 2-digit base-16 byte pairs representing Red, Green, and Blue intensity from 00 (0 decimal) to FF (255 decimal). For each pair, multiply the first hex digit by 16 and add the second hex digit: for #0EA5E9, Red = 0×16 + 14 = 14, Green = 10×16 + 5 = 165, and Blue = 14×16 + 9 = 233, giving rgb(14, 165, 233). For 3-digit shorthand (#0AF), duplicate each nibble first (#00AAFF) before converting.

What is the difference between HSL, HSV (HSB), and OKLCH?

HSL (Hue, Saturation, Lightness) places pure saturated colors at L = 50% and pure white at L = 100%, whereas HSV/HSB (Hue, Saturation, Value/Brightness, used in Figma and Photoshop) places pure vivid colors at V = 100% and S = 100%. However, neither HSL nor HSV is perceptually uniform—pure yellow (#FFFF00, Y = 0.928) and pure blue (#0000FF, Y = 0.072) share L = 50% in HSL despite yellow appearing 13× brighter. OKLCH (W3C CSS Color Module Level 4) solves this by modeling human cone perception so equal L values have identical perceived lightness across all hues.

Why do vivid RGB screen colors look duller when converted to CMYK for printing?

Computer and smartphone displays use additive light (sRGB / Display-P3) emitted directly from red, green, and blue subpixels, whereas commercial offset printing uses subtractive cyan, magenta, yellow, and black (CMYK) inks that absorb light on paper. High-chroma neon greens, electric blues, and vivid cyans lie outside the physical reflective gamut of CMYK inks, and press standards (ISO 12647-2 / SWOP) cap Total Area Coverage (TAC = C + M + Y + K) at 300% to prevent ink set-off.

What WCAG contrast ratio is required for accessible web text?

Under WCAG 2.1 Success Criterion 1.4.3 (Level AA), normal body text (< 18pt / 24px regular or < 14pt / 18.66px bold) requires a minimum contrast ratio of 4.5:1, while large text and non-text UI components/icons (SC 1.4.11) require at least 3.0:1. Enhanced Level AAA (SC 1.4.6) requires 7.0:1 for normal text and 4.5:1 for large text, computed as (L_lighter + 0.05) / (L_darker + 0.05) from linearized sRGB relative luminance.

Related Concepts & Terminology

Regulatory & Advisory Disclaimer: Empirical Estimations Only

Calculations and projections displayed by the Color Converter represent mathematical baselines and do not constitute formal financial, medical, legal, engineering, or academic registrar advice. Always verify critical figures with a qualified professional or official institutional syllabus.