Color Converter & Gamut Mapper (OKLCH, Lab, P3)
Convert any CSS color to HEX, RGB, HSL, Lab, LCH, OKLab, OKLCH and Display P3.
Try an example: A vivid OKLCH green outside sRGB · A deep teal HEX code · A CSS named color · Display P3 red
How it works
Paste a HEX code, CSS named color or any CSS Color 4 function. Get every color space, sRGB and Display P3 gamut checks, the CSS gamut-mapped HEX instead of naive clipping, WCAG contrast against white and black, and the nearest CSS named colors by CIEDE2000.
- Parse the color with CSS Color 4 syntax: HEX (3, 4, 6 or 8 digits), the 148 named colors, rgb(), hsl(), hwb(), lab(), lch(), oklab(), oklch() and color() with srgb, srgb-linear, display-p3, a98-rgb, prophoto-rgb, rec2020, xyz-d50 and xyz-d65. The keyword none counts as zero.
- Convert through CIE XYZ (D65) with the matrices of the CSS Color 4 sample code. Lab and LCH use the D50 white with the Bradford adaptation, as in CSS. OKLab and OKLCH follow Ottosson (2020).
- A color is in a gamut when every encoded channel lies within 0–1 (tolerance 0.000075). Out-of-gamut colors are mapped with the CSS Color 4 binary search: reduce OKLCH chroma at constant lightness and hue until clipping changes the color by less than one just-noticeable difference (deltaEOK 0.02). The plainly clipped HEX is shown for comparison.
- HSL, HWB, RGB and the WCAG contrast ratios describe the mapped 8-bit sRGB color. Nearest named colors are ranked by CIEDE2000 in CSS Lab.
Sources
- CSS Color Module Level 4 (color spaces, gamut mapping, named colors, sample code) (W3C)
- Björn Ottosson (2020): A perceptual color space for image processing (Oklab) (Björn Ottosson)
- Sharma, Wu and Dalal (2005): The CIEDE2000 color-difference formula — implementation notes, supplementary test data (University of Rochester)
- WCAG 2.2: Contrast (Minimum), relative luminance (W3C)
Part of Lumina
-
Lumina Photo editor & image toolkit
Bring out what you saw. A free photo studio, right in your browser.
Related tools
- Delta E Color Difference (CIEDE2000) – Measure color differences with CIEDE2000, CIE94, CIE76 and OKLab, with a pass/fail tolerance.
- OKLCH Palette & Tint Scale Generator – Build perceptually even tint scales and hue harmonies in OKLCH, gamut-mapped for CSS.
- Color Blindness Palette Simulator – Simulate protan, deutan and tritan vision for a palette and find colors that become confusable.
- Palette Contrast Matrix – Check every palette color pairing against WCAG text contrast thresholds.
How to convert CSS colors to OKLCH, Lab and Display P3
Convert HEX, names and any CSS Color 4 value into every color space, see gamut status and get the CSS gamut-mapped HEX instead of clipping.
What it is for
Modern CSS lets you write colors as oklch(), lab() or color(display-p3 …), but design files, brand sheets and older code still speak HEX and RGB. This converter takes one color in any of those notations and shows it in all of them at once: HEX, RGB, HSL, HWB, CIELAB and LCH (with the D50 white CSS uses), OKLab, OKLCH, Display P3 and CIE XYZ.
It also answers the question the other converters skip: what happens when a color does not fit on an ordinary screen? Vivid OKLCH and P3 colors often lie outside sRGB. The tool tells you whether the color is inside the sRGB and Display P3 gamuts and gives the HEX that a browser following CSS Color 4 would show, next to the cruder clipped value. Finally it lists the nearest of the 148 CSS named colors and the WCAG contrast against white and black.
It does not handle CMYK, ICC profiles or paint and print libraries.
Worked example
Enter hsl(330 100% 40%) and ask for three named colors. The tool answers that the color is #CC0066 in sRGB and oklch(0.5457 0.2203 2.11) in OKLCH. It is inside both gamuts. The table gives lab(44.58 70.91 4.39), lch(44.58 71.04 3.54) and color(display-p3 0.7331 0.1519 0.3977). Contrast is 5.59:1 against white and 3.76:1 against black, so white text on this magenta passes WCAG AA for normal text. The closest named color is mediumvioletred at ΔE2000 7.53 — noticeably different, so the name is a description, not a match.
Now try color(display-p3 0 1 0), the greenest green a P3 display can show. The tool warns that it is outside sRGB: the gamut-mapped HEX is #00FB29, while plain clipping would give #00FF00. Gamut mapping keeps the OKLCH lightness and hue and only reduces chroma until the result is within one just-noticeable difference of the clipped color, so the fallback looks like the same green, just less intense. The nearest named color is lime (ΔE2000 5.21).
How to read the result
- HEX (sRGB) is what to use as a fallback or in tools that only accept HEX. For out-of-gamut input it is the CSS gamut-mapped value; RGB, HSL, HWB and the contrast ratios describe this mapped color.
- Inside sRGB / Inside Display P3 tell you whether the color survives unchanged on standard and wide-gamut screens.
- The color spaces table gives ready-to-paste CSS values. Lab and OKLab values are of the original color, so you can round-trip a P3 color without losing it.
- Nearest CSS named colors are ranked by CIEDE2000. Below about 1 they look identical; above 5 the name is only a rough family.
Tips and common mistakes
- Use OKLCH for edits: change only L to get lighter or darker versions with the same hue.
lab()in CSS uses the D50 white. Lab values from Photoshop or a spectrophotometer set to D65 will not match.- Achromatic colors such as
#808080have no hue; the tool writesnone, which is valid CSS. - Eight-digit HEX and
/ 50%alpha are kept in the CSS values, but contrast assumes an opaque color. - Gamut mapping is not clipping. If the mapped and clipped HEX differ a lot, design with the mapped one.
FAQ
Why is my OKLCH color shown with a different HEX in another tool?
Many converters clip each RGB channel to 0–255, which can shift hue. This tool uses the CSS Color 4 algorithm, so its HEX matches what browsers aim to render.
Which named color list is used?
The 148 CSS named colors from CSS Color Level 4. Synonyms such as gray and grey share one value.
Can I paste a P3 color from a design tool?
Yes, as color(display-p3 r g b) with channels from 0 to 1. The tool converts it exactly.
Is the OKLCH lightness the same as HSL lightness?
No. OKLCH lightness follows perceived brightness, so yellow and blue at the same L really look equally light; HSL does not.
Guide last updated:
For scripts and AI agents
- JSON API:
POST https://luminacolorconverter.usefulweb.app/api/v1/calculate(same calculation as this page) - Interface description: OpenAPI 3.1 · AI guide: llms.txt
- MCP server (Streamable HTTP):
https://luminacolorconverter.usefulweb.app/mcp· tool namelumina_color_converter
Example request
curl -s -X POST https://luminacolorconverter.usefulweb.app/api/v1/calculate \
-H 'content-type: application/json' \
-d '{"color":"oklch(0.7 0.25 145)","nearest":5}'