Skip to content
search-engine-optimizedby Netsolution
  1. Home
  2. Utilities
  3. RGB to Hex

RGB to Hex

Convert a colour code from one format to another, with no mental arithmetic.

Conversions computed locally between RGB, hexadecimal, HSL and oklch, transparency included. Nothing is stored, and there is no usage limit.

What this tool is for

A colour can be written in several ways that designate strictly the same thing. Design software gives RGB values, a brand guideline supplies hexadecimal, a modern stylesheet happily uses HSL. Moving from one to another by hand is tedious and error-prone.

This tool converts in every direction, transparency included. It adds the newer oklch format, whose value is real: two colours of the same lightness there genuinely look equally bright, which is not true in HSL.

It also shows the contrast ratio, because a conversion nearly always serves to apply a colour somewhere — and the first question to ask is whether the text will stay readable.

To build a palette: work in HSL or oklch. Keeping the hue and varying only the lightness produces a coherent range in seconds, where hexadecimal forces you to recompute every shade.

How to read the results

Hexadecimal encodes the three components on two characters each, from 00 to ff. It is the most widespread format in brand guidelines and the handiest to copy.

RGB expresses the same components as decimal values from 0 to 255. The four-value variant adds transparency, from 0 to 1.

HSL breaks down into hue from 0 to 360 degrees, saturation and lightness as percentages. It is the format that makes variations legible by eye in the code itself.

oklch expresses perceived lightness, chroma and hue. Its superiority lies in its fidelity to human perception, which avoids palettes where certain shades look inexplicably heavier.

The contrast is computed against white and black. The color picker sets out the corresponding accessibility thresholds.

Common mistakes

Confusing HSL with HSB. Design software often uses HSB, the web uses HSL. The two look alike and do not give the same values: a colour copied as-is will be wrong.

Forgetting the alpha channel. Converting a transparent colour while ignoring the transparency gives a solid colour, often far denser than expected.

Recomputing every shade by hand. Lightening a colour in hexadecimal means handling three components. In HSL, one number changes.

Trusting the rendering of a single screen. Panels render differently. A colour approved on a calibrated screen can surprise elsewhere.

Converting without checking the contrast. A successful conversion of an unreadable colour is still an unreadable colour. Check the ratio before applying it.

Going further

Frequently asked questions

Why hexadecimal rather than RGB?

For brevity and out of habit. #1a56c4 is shorter than rgb(26, 86, 196) and copies in one piece. Technically the two notations designate exactly the same colour: the browser treats them identically. The choice is a matter of writing comfort.

What do the three characters of a short code mean?

It is an abbreviation valid when the character pairs are identical: #1a2b3c cannot be shortened, but #112233 is written #123. Each character is simply doubled when interpreted. Handy, but few colours lend themselves to it.

How do I add transparency?

Two ways. In RGB, the four-value notation adds an alpha channel from 0 to 1. In hexadecimal, two extra characters at the end of the code do the same job: #1a56c480 corresponds to about 50 % opacity. Both are recognised by every current browser.

What does the HSL format bring?

Intuition. Lightening a colour in hexadecimal means recomputing three components; in HSL, you just raise the lightness. That is what makes it the handiest format for building a coherent palette from a single hue.

Why does my colour look different on different screens?

Because every panel renders colour its own way, according to its calibration and its technology. The same code can look cooler or more saturated from one screen to the next. One more reason never to rest information on a colour shade alone.

What are oklch and the recent colour spaces?

Notations closer to human perception, now recognised by modern browsers. In oklch, two colours of the same lightness genuinely look equally bright, which is not the case in HSL. It is a real advance for building balanced palettes.