>_ MoriDev dev.moritools.com
OKLCH · WCAG 2.1 100% Client-Side · Zero Upload

HEX / RGB / HSL / OKLCH Color & Tailwind Shade Converter

Convert HEX, RGB, HSL, and CSS Color 4 OKLCH with live WCAG 2.1 AA/AAA contrast checks and an 11-step Tailwind palette generator.

Ready (Offline)
Quick Summary

Type any HEX, rgb(), hsl(), or oklch() value—or use the native color picker—to inspect exact conversions across all four color spaces, audit WCAG 2.1 AA/AAA text contrast against white, black, or custom surfaces, and copy an 11-step OKLCH Tailwind scale.

Traditional HSL lightness misleads designers: hsl(60, 100%, 50%) yellow appears blindingly bright while hsl(240, 100%, 50%) blue appears dark despite sharing identical 50% L values. That perceptual distortion creates inconsistent hover states and failing contrast ratios across themes.

Tailwind CSS v4 and CSS Color Level 4 embrace OKLCH (Lightness, Chroma, Hue) based on Björn Ottosson’s perceptual LMS matrices. This tool runs exact sRGB ↔ Linear RGB ↔ OKLCH math in-browser while computing real-time WCAG 2.1 relative luminance and contrast thresholds.

Design System Color & Contrast Pitfalls

01. Using HSL Lightness Steps for Accessible Color Scales

Stepping HSL L by 10% produces muddy yellows and unreadable blues at the same numeric token (e.g., 500). Generating 50–950 ramps in OKLCH keeps perceived brightness consistent across every hue.

02. Ignoring WCAG Normal vs Large Text Thresholds

Body copy under 18pt (or 14pt bold) requires at least 4.5:1 contrast for WCAG AA and 7.0:1 for AAA. Many vibrant brand greens pass Large Text (3.0:1) on white yet fail body text readability.

03. Forgetting Gamma Linearization Before Luminance Math

sRGB bytes are gamma-encoded (~2.2 curve). Computing luminance directly from raw 0–255 channels distorts mid-tone contrast ratios; WCAG 2.1 mandates expanding each sRGB channel to linear light first.

WCAG 2.1 Contrast Threshold Reference

Conformance Level Normal Text (<18pt) Large Text (≥18pt / 14pt Bold)
WCAG AA (Minimum) ≥ 4.5 : 1 contrast ratio ≥ 3.0 : 1 (also UI icons & borders)
WCAG AAA (Enhanced) ≥ 7.0 : 1 contrast ratio ≥ 4.5 : 1 contrast ratio
OKLCH Lightness (L) 0.0 (black) to 1.0 (white) Perceptually uniform across hues
OKLCH Chroma (C) 0.0 (neutral gray) to ~0.37 Controls vividness without hue shift

Worked Engineering Examples

Auditing Emerald Accent (#10B981) on Dark IDE Canvas (#090B10)

Input
Foreground: #10B981 · Background: #090B10
Output
oklch(0.6959 0.1491 162.48) · Contrast on #090B10: 7.75:1 (Passes AA & AAA)

On dark surfaces #10B981 exceeds AAA (7.75:1), whereas on white (#FFFFFF) its 2.53:1 ratio warns you to step down to shade 600/700 for light-mode text.

Converting CSS Color 4 OKLCH Back to Legacy HEX

Input
oklch(0.685 0.169 237.323)
Output
HEX #00A6F4 · rgb(0, 166, 244) · hsl(199.2, 100%, 47.8%)

Translates Tailwind v4 OKLCH tokens into HEX/RGB equivalents for Figma, email templates, or SVG assets.

Frequently Asked Questions

Why does Tailwind CSS v4 default to OKLCH colors?

OKLCH provides predictable perceptual brightness and clean P3 wide-gamut support, so shade 600 of blue, green, and amber deliver comparable visual weight and contrast.

Can I paste an OKLCH value with percentage lightness like oklch(69.6% 0.17 162)?

Yes. The parser accepts both decimal (0–1) and percentage (0%–100%) OKLCH lightness syntax alongside HEX (#RGB / #RRGGBB), rgb(), and hsl().

How does the custom background contrast checker work?

Enter your exact app surface color (for example #0F131A in dark mode or #F8FAFC in light mode) to inspect live AA and AAA pass/fail badges alongside white and black defaults.

Can I click any generated 50–950 Tailwind shade to copy it?

Yes. Clicking any swatch card copies its HEX value to your clipboard immediately, and Download exports the entire CSS custom property palette.

Continue Your Workflow

24 offline developer utilities