ximg.es

Colour converter

Type a colour in any CSS format (or pick one) and get it in HEX, RGB, HSL, HWB and OKLCH, with its CSS name and the ximg.es image in that colour.

Try
The colour in each format
HEX #2563eb
RGB rgb(37, 99, 235)
HSL hsl(221, 83.2%, 53.3%)
HWB hwb(221 14.5% 7.8%)
OKLCH oklch(54.61% 0.215 262.9)
CSS name royalblue (closest match)
ximg.es URL https://ximg.es/600x300/2563eb/fff
ximg.es image with the chosen colour as background

Which colour format to use

Why OKLCH is in fashion

In HSL, a yellow and a blue at 50% lightness look nothing alike in brightness. In OKLCH they do, which lets you build consistent colour scales (100, 200… 900) by changing only L, and gradients without the grey patch in the middle. It can also describe colours more vivid than sRGB for P3 displays; when that happens, the tool warns you and shows the closest representable colour in HEX and RGB. Every current browser understands oklch().

Colours in ximg.es URLs

The placeholder generator takes the background and text colours in the URL itself, in hexadecimal without the hash: /600x300/2563eb/fff. It accepts 3, 4, 6 and 8 digits (4 and 8 carry transparency in PNG, WebP and AVIF), the 1- and 2-digit shortcuts (c is cccccc) and the 148 CSS names: /600x300/tomato/white. The converter’s last row gives you the URL with white or black text, whichever has the better contrast.

CSS colour names

CSS has 148 names, from aliceblue to yellowgreen. If the colour has no name of its own, the tool finds the one that looks closest (distance is measured in OKLab, not RGB), which is handy for naming variables or describing a colour in conversation.

Frequently asked questions

How do I convert HEX to RGB?

Each pair of digits is a channel in hexadecimal: in #2563eb, 25 is 37 red, 63 is 99 green and eb is 235 blue. Type it above and it’s converted for you.

What is an 8-digit HEX colour?

A HEX with transparency: the last two digits are the alpha, from 00 (transparent) to ff (opaque). 80 is roughly 50%.

What’s the difference between HSL and OKLCH?

Both separate hue, intensity and lightness, but OKLCH is calibrated to human perception: the same lightness looks equally light in any hue. In HSL, yellow at 50% looks much lighter than blue at 50%.

Can I use OKLCH in production?

Yes. Chrome, Edge, Firefox and Safari have supported it since 2023. If you have to support older browsers, declare the same property in HEX first as a fallback.

Why does my OKLCH colour come out different in HEX?

Because OKLCH can describe colours that don’t fit in sRGB, the space HEX and RGB use. The closest colour inside sRGB is shown and the tool warns you.

Which colours does ximg.es accept in the URL?

Hexadecimal without # with 1, 2, 3, 4, 6 or 8 digits, and the 148 CSS names. For example, https://ximg.es/600x300/2563eb/fff or https://ximg.es/600x300/navy/gold.

More tools

See all tools · Placeholder image generator