CSS Color Format Converter
Turn one colour into every modern CSS syntax at once: hex, rgb, hsl, hwb, lab, lch, oklab, oklch and display-p3, each with its own copy button.
Preview
Every modern CSS colour syntax
What is the CSS Color Format Converter?
CSS now has far more ways to write a colour than it used to, and different tools want different ones.
- Eleven output syntaxes from a single input colour
- Per-format copy buttons plus a copy-everything option
- Exact CSS Color 4 matrices, so white converts to lab(100% 0 0)
- Reports the chroma headroom left before you leave sRGB
- Accepts hex shorthand, full hex and rgb() triples
- 100% client-side — colours never leave your machine
How to use the CSS Color Format Converter
- 1
Enter a colour as a hex value or an rgb() triple, or pick one with the swatch.
- 2
Check the preview swatch and the sRGB gamut read-out at the top.
- 3
Scroll the list of syntaxes and press Copy beside whichever one your tool needs.
- 4
Use Copy all formats to grab the whole set as a reference block.
About the CSS Color Format Converter
CSS now has far more ways to write a colour than it used to, and different tools want different ones. Figma exports hex, a design system might store hsl, Tailwind v4 emits oklch, and a wide-gamut photo pipeline wants display-p3. This converter takes one colour and produces every one of those syntaxes side by side.
The conversions go through the proper chain rather than a lookup table: sRGB is linearised, multiplied by the CSS Color 4 matrix into CIE XYZ at the D65 white point, then transformed into Lab, LCH, OKLab, OKLCH or Display P3 as needed. The matrices are the exact ones browsers use, so pure white lands on lab(100% 0 0) rather than something a fraction off.
All the maths happens locally in your browser. Nothing you paste is sent to a server, and the tool keeps working with no connection once the page has loaded.
Frequently asked questions
What is the difference between lab() and oklab() in CSS?
Both are perceptual spaces, but oklab() is a newer model tuned to fix a known weakness in CIELAB: blues shift hue as you change lightness. If you are building a ramp of tints and shades, oklab and oklch will hold the hue steadier. For simple colour matching, either works.
When should I use color(display-p3 …)?
Use it when you want a colour more saturated than sRGB can produce on displays that support it. Note that converting an sRGB colour to display-p3 does not make it more vivid — it is the same colour, addressed in a wider coordinate system.
What is hwb() and why would I use it?
HWB describes a colour as a hue plus how much white and how much black are mixed into it, which is close to how people mix paint. It is often the most intuitive syntax for hand-tuning tints and shades of a single hue.
Are these CSS color functions safe to use in production?
hex, rgb and hsl are universally supported. hwb, lab, lch, oklab and oklch have been supported across current Chrome, Edge, Safari and Firefox since 2023. If you need to support older browsers, put the hex value first as a fallback declaration.
Why do rgb(59 130 246) and rgb(59, 130, 246) both appear?
CSS Color 4 introduced the space-separated form, and every current browser accepts it. The comma form is still valid and is what a lot of older tooling and preprocessors expect, so both are offered.
Related tools
OKLCH Color Converter
Convert HEX and RGB to OKLCH or OKLab and back, with a live swatch, gamut warnings and ready-to-paste oklch() CSS for Tailwind v4.
RGB to LAB Color Converter
Convert sRGB or HEX to CIELAB and back through CIE XYZ at the D65 white point, with every intermediate step shown and out-of-gamut warnings.
RGB to HSV/HSB Converter
Convert HEX or RGB to HSV (the HSB model in Photoshop and Figma) and back, with the HSL equivalent shown beside it so you can see why they disagree.
HEX to RGB Converter
Convert HEX color codes to RGB and RGBA instantly. Supports 3, 6 and 8-digit HEX with a live color swatch, batch list conversion and one-click copy.
HEX to HSL Converter
Convert HEX color codes to HSL and HSLA instantly. See hue, saturation and lightness values with a live swatch, batch list conversion and copy button.