induwara.lk
induwara.lkDeveloper · Browser-only

Color Converter — HEX, RGB, HSL, HSV, CMYK & OKLCH

Paste any color in any format and get every other format back, with WCAG contrast against white and black, the nearest CSS named color, and a color-blindness simulation. Runs entirely in your browser.

By Induwara AshinsanaUpdated May 11, 2026
Convert any colorHEX · RGB · HSL · HSV · CMYK · OKLCH

Parsed as HEX · paste any HEX, RGB, HSL, OKLCH, or CSS name.

Quick swatches
#1A73E8

Aa Bb 123

On white4.51:1 · AA

Aa Bb 123

On black4.66:1 · AA

All formats

HEX

#1A73E8

RGB

rgb(26, 115, 232)

HSL

hsl(214.1, 81.7%, 50.6%)

HSV / HSB

hsv(214.1, 88.8%, 91%)

CMYK

cmyk(89%, 50%, 0%, 9%)

OKLCH

oklch(57.4% 0.1946 257.9)

Nearest named

dodgerblue

Color-vision simulation

Normal vision
ProtanopiaRed-blind · ~1% of men
DeuteranopiaGreen-blind · ~1% of men
TritanopiaBlue-blind · very rare
AchromatopsiaTotal color-blindness · 1 in 33,000

Conversions follow the W3C CSS Color Module Level 4. CMYK uses the un-color-managed identity formula (the only formula a tool without an embedded ICC profile can ship honestly). Color-vision simulation uses the Viénot–Brettel–Mollon (1999) matrices and a BT.709 luminance approximation for achromatopsia. Last verified 2026-05-11.

How it works

The tool keeps one canonical representation of every color — an integer sRGB triple plus an alpha — and derives every output format from it. That means whichever format you paste, the other six are computed from a single source of truth, so they always agree to the rupee (or in this case, to the channel).

HSL and HSV. Both come from the same RGB extremes — the maximum and minimum channel set the hue angle and the saturation, while the lightness (HSL) or value (HSV) is computed from the bounds. The exact pseudocode lives in CSS Color Module Level 3, §4.2; OKLCH was added in Level 4. HSL is what designers expect; HSV (also called HSB) is what Photoshop, Affinity, and Figma show in their swatch panel. Both round-trip back to RGB to within 1 of 255.

CMYK. The page uses the un-color-managed identity formula: K = 1 − max(R, G, B) and C = (1 − R − K) / (1 − K) (and likewise for M and Y). Real-world print pipelines apply an ICC profile that knows your paper and ink set, but no in-browser tool can ship that for you — so the output here is a sanity-check starting point, not a press-ready separation. Adobe's own documentation describes the same identity transform.

OKLCH.sRGB is gamma-decoded to linear sRGB, multiplied through the LMS matrix from Björn Ottosson's OKLab paper, cube-rooted to LMS', multiplied again to OKLab, and finally converted to polar form (L, C, h). This is the algorithm CSS Color Module Level 4 normatively cites. The inverse is exposed too, so pasting oklch(60% 0.15 250) gives you the corresponding sRGB. Out-of-gamut OKLCH values are clamped per channel back into 0–255 — that's the only way to render them on an sRGB monitor, and the tool tells you when it happens via the parser hint.

Named colors.The 148 CSS named colors from CSS Color Module Level 4 §6.5 are stored as a plain table; pasting a name resolves to its exact RGB, and any RGB resolves to the nearest name by squared sRGB distance. The "Nearest" vs "Named" label tells you whether the match is exact or approximate.

WCAG contrast. Each channel is gamma-decoded with the sRGB transfer function, weighted by the BT.709 luminance coefficients (0.2126 R + 0.7152 G + 0.0722 B), and compared against pure white and pure black. The 4.5:1 (AA) and 7:1 (AAA) thresholds for body text come straight from WCAG 2.2 §1.4.3.

Color-vision simulation. The protanopia, deuteranopia, and tritanopia tiles use the Viénot–Brettel–Mollon (1999) display-space matrices applied directly to sRGB. Achromatopsia uses BT.709 luminance for an honest monochrome rendering. These match what the well-known Coblis and Daltonize tools render — useful for design QA, not a substitute for a real observer or a calibrated medical instrument.

Every conversion is silently round-trip verified against a fixed sample set (black, white, the primaries, sky-blue, the brand saffron, rebeccapurple, and a mid-gray). The result is shown as a badge in the calculator header — the same credibility check as the JSON formatter on this site.

Worked examples

Pure red — RGB(255, 0, 0)

Input: #FF0000

  1. RGB: rgb(255, 0, 0)
  2. HSL: hsl(0°, 100%, 50%) — max=R, min=G=B, L=0.5, S=d/(max+min)=1
  3. HSV: hsv(0°, 100%, 100%) — V=max=1, S=d/V=1
  4. CMYK: cmyk(0%, 100%, 100%, 0%) — K=1-max=0, M=Y=1
  5. OKLCH: oklch(62.8% 0.258 29.2°) — per Ottosson's reference
  6. Named: red (exact)
  7. Contrast: vs white 4.0:1 (AA Large) · vs black 5.3:1 (AA)

Sky blue — RGB(135, 206, 235)

Input: #87CEEB

  1. RGB: rgb(135, 206, 235)
  2. HSL: hsl(197°, 71%, 73%) — L=(0.92+0.53)/2≈0.73, S=d/(2-max-min)≈0.71
  3. HSV: hsv(197°, 43%, 92%) — V=0.92, S=d/V≈0.43
  4. CMYK: cmyk(43%, 12%, 0%, 8%) — K=1-0.92≈0.08
  5. Named: skyblue (exact)
  6. Contrast: vs white 1.6:1 (Fail) · vs black 13.4:1 (AAA)

Black — RGB(0, 0, 0) (edge case)

Input: #000000

  1. RGB: rgb(0, 0, 0)
  2. HSL: hsl(0°, 0%, 0%) — d=0 → S=0, H undefined → 0 by convention
  3. HSV: hsv(0°, 0%, 0%) — V=0 → S=0 (avoid /0)
  4. CMYK: cmyk(0%, 0%, 0%, 100%) — K=1, special case where C=M=Y=0
  5. OKLCH: oklch(0% 0 0°)
  6. Named: black (exact)
  7. Contrast: vs white 21:1 (AAA) · vs black 1:1 (Fail)

Frequently asked questions

Sources & references

Related tools

Rate this tool
Be the first to rate

Comments & feedback

Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.

Found a bug, edge case, or want to suggest an improvement?

Email me at [email protected] — most fixes ship within 24 hours.