regula.tools
100% Client-SideMedia & Graphics

HEX, RGB, HSL & OKLCH Color Converter + WCAG Checker

Convert any color seamlessly between HEX (`#RRGGBB`), `rgb()`, `hsl()`, modern CSS Color 4 `oklch()`, print `cmyk()`, and CSS named colors. Preview live swatches and verify WCAG 2.1 AA / AAA contrast ratios against white, black, or any custom background directly in your browser.

Loading workspace...

#How to Use This Tool

1Type or paste any HEX, RGB, HSL, OKLCH, or CSS named color (such as `rebeccapurple` or `coral`), or use the visual color picker.
2Copy any converted format (`HEX`, `RGB`, `HSL`, `OKLCH`, `CMYK`) with a single click.
3Enter a custom background color to test real-time WCAG 2.1 AA and AAA accessibility compliance.
4Share the exact color & background pairing via Mode A query parameters (`?color=...&bg=...`).

#Mathematical Formula & Standards

sRGB channels ($0\text{–}255$) are linearized using the IEC 61966-2-1 gamma transfer function ($c \le 0.04045 \Rightarrow c/12.92$, else $((c+0.055)/1.055)^{2.4}$) before transforming into Björn Ottosson’s perceptually uniform OKLab / OKLCH space (`oklch(L C H)`). WCAG 2.1 relative luminance is $Y = 0.2126 R_{lin} + 0.7152 G_{lin} + 0.0722 B_{lin}$, and contrast ratio is $(Y_{light} + 0.05) / (Y_{dark} + 0.05)$, requiring $\ge 4.5:1$ for AA normal text and $\ge 7.0:1$ for AAA normal text.

#Edge Cases & Technical Considerations

Why OKLCH Beats HSL for UI Design Systems

HSL lightness is not perceptually uniform—yellow (`hsl(60, 100%, 50%)`) looks far brighter to the human eye than blue (`hsl(240, 100%, 50%)`). OKLCH keeps perceived lightness (`L`) consistent across all hues (`H`).

sRGB Gamut Clamping

Wide-gamut OKLCH colors with high chroma (`C`) outside the sRGB gamut are clamped channel-wise when converted to 8-bit HEX and `rgb()`.

WCAG 2.1 AA vs. AAA Thresholds

WCAG AA requires `4.5:1` for normal body text (`3.0:1` for large text >= 18pt or 14pt bold). WCAG AAA raises the bar to `7.0:1` for normal text and `4.5:1` for large text.

#Frequently Asked Questions

Q:What color formats can I paste into the input?

You can paste 3/6/8-digit HEX (`#10B981`, `#f00`), `rgb(...)`, `hsl(...)`, CSS Color 4 `oklch(L C H)`, or standard CSS color names like `coral`, `teal`, and `rebeccapurple`.

Q:How is WCAG 2.1 contrast ratio calculated?

The engine linearizes sRGB channels, computes relative luminance (0 for black, 1 for white), and divides `(L_lighter + 0.05) / (L_darker + 0.05)` to evaluate AA and AAA thresholds.

Q:Are my design tokens or brand colors sent to a server?

No. All color space conversions and contrast calculations run 100% client-side in your browser.

Have feedback or feature requests?

Help us improve this utility. Share suggestions, report edge cases, or request new features directly.

Send Feedback