# Color Converter & Gamut Mapper (OKLCH, Lab, P3) > Convert any CSS color to HEX, RGB, HSL, Lab, LCH, OKLab, OKLCH and Display P3. 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. Part of usefulweb.app (https://usefulweb.app/). Part of [Lumina](https://lumina.usefulweb.app/) (ownerApp: lumina). Results are deterministic calculations from the inputs and the listed assumptions; the API returns exactly what the web page shows. ## Use it - Human interface: https://luminacolorconverter.usefulweb.app/ (interactive tool at https://luminacolorconverter.usefulweb.app/tool) - JSON API: POST https://luminacolorconverter.usefulweb.app/api/v1/calculate with a JSON object of inputs (schema: https://luminacolorconverter.usefulweb.app/api/v1/tool) - OpenAPI: https://luminacolorconverter.usefulweb.app/openapi.json - MCP (Streamable HTTP): https://luminacolorconverter.usefulweb.app/mcp - tool `lumina_color_converter` ## Inputs - color (text): CSS color (HEX, name, rgb(), hsl(), hwb(), lab(), lch(), oklab(), oklch() or color()) - nearest (integer): Nearest CSS named colors to list ## Method - 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.