Color Converter
Convert between HEX, RGB, HSL, OKLCH, LAB, and P3, with WCAG contrast.
- Your draft is kept in this tab's session storage and cleared when the tab closes.
Draft kept in this tab
Your draft is kept in this tab's session storage and cleared when the tab closes. - Processing happens in this page. No application server receives your input.
Runs in your browser
Processing happens in this page. No application server receives your input.
CSS color input
Converted color
- Primary output
- Target format
- RGB (rgb)
- sRGB gamut
- โ
- Contrast on white (#ffffff)
- โ
- Contrast on black (#000000)
- โ
Color representations
| Format | Converted value | Action |
|---|---|---|
| Enter a valid CSS color to view HEX, RGB, HSL, and OKLCH representations. | ||
What this tool does
Converts CSS colors between HEX, RGB, HSL, OKLCH, and standard CSS named forms synchronously in-page, reports whether wide-gamut inputs lie within the sRGB gamut, and computes WCAG 2.1 contrast ratios against white (#ffffff) and black (#000000).
Conversion & WCAG contrast rules
- Accepts 3-, 4-, 6-, and 8-digit hexadecimal strings (#rgb, #rgba, #rrggbb, #rrggbbaa), CSS Named Colors (such as rebeccapurple or transparent), rgb()/rgba(), hsl()/hsla(), and oklch() functional notations.
- Preserves alpha channels across all target formats (emitting 8-digit hex for alpha < 1 in HEX mode and / alpha in RGB, HSL, and OKLCH modes).
- Reports out-of-gamut OKLCH inputs explicitly (inSrgbGamut: false) rather than silently clamping them without notice.
- Computes WCAG 2.1 relative luminance and contrast ratios against white (#ffffff) and black (#000000), rounding conservatively at the chosen precision so a ratio strictly below 4.5 (AA) or 7.0 (AAA) never rounds up across the threshold.
- Treats empty or whitespace-only input as the neutral cleared state with empty output and no error (GAP-013).
Operational limits & execution
Maximum input length: 256 characters (returns InputTooLarge above the cap). Unrecognized or malformed color syntax returns UnparseableColor naming the offending input.
Runs synchronously in-page with zero external runtime calls.
Worked example
Input:
#ff0000Expected output:
rgb(255 0 0) contrast on white 3.998 contrast on black 5.252Scope: this covers the page itself. Your browser, operating system, clipboard, downloads, extensions, and crash recovery may keep copies, and a compromised site origin would not be protected.