Color converter

Convert color values between HEX, RGB, and HSL formats instantly. Enter a value in any format, pick from the color wheel, or paste a CSS color — all three representations update in real time.

CSS snippet
color: #F97316; /* rgb(249, 115, 22) — hsl(24, 95%, 53%) */

Understanding color formats in web development

Web developers work with three primary color formats when writing CSS and designing interfaces. Each format describes the same visual color in a different mathematical way, and choosing the right format for each use case can make your code more readable, maintainable, and flexible. Most modern browsers and design tools support all three formats interchangeably.

HEX color codes

HEX (hexadecimal) color codes are the most widely recognised format in web development. They represent a color as a six-character string prefixed with a hash (#), where each pair of characters represents the red, green, and blue channel values in hexadecimal notation from 00 (minimum, 0 in decimal) to FF (maximum, 255 in decimal). For example, #F97316 breaks down as F9 (249 red), 73 (115 green), 16 (22 blue).

HEX codes can also be written in shorthand when each pair repeats — #FF6600 can be written as #F60. An 8-character HEX code includes an alpha (transparency) channel: #F97316CC where CC is 80% opacity. HEX is the most compact notation and is universally supported, making it the default choice for design system tokens, CSS variables, and any context where brevity matters.

RGB color format

RGB (Red, Green, Blue) represents a color as three decimal values, each from 0 to 255, in the CSS function notation rgb(249, 115, 22). This format is more immediately readable than HEX for developers who think in decimal. The equivalent with transparency is rgba(249, 115, 22, 0.8) where the fourth value is the alpha channel from 0 (transparent) to 1 (fully opaque). In CSS Color Level 4, the modern syntax allows rgb(249 115 22) without commas and rgb(249 115 22 / 80%) for transparency.

RGB is particularly useful when you need to manipulate color values programmatically — for example, when building a colour picker, applying tints, or animating between two colors. It is also the format most directly related to how displays physically produce colour by mixing light from red, green, and blue sub-pixels.

HSL color format

HSL (Hue, Saturation, Lightness) is a human-intuitive colour model that describes colour in terms of perceptual properties rather than hardware characteristics. Hue is a degree on the colour wheel from 0 to 360 (0 = red, 120 = green, 240 = blue). Saturation is a percentage from 0% (grey) to 100% (full colour). Lightness is a percentage from 0% (black) to 100% (white), with 50% being the "pure" colour.

HSL is invaluable for creating colour palettes and themes programmatically. To create a lighter tint of a colour, simply increase the lightness. To create a muted version, decrease the saturation. To create harmonious colour combinations, vary only the hue. CSS preprocessors like Sass have built-in HSL manipulation functions, and CSS Custom Properties make it easy to build theme systems based on HSL values.

Choosing the right format

Use HEX for design tokens, colour palettes in documentation, and any context where the value is copied from a design tool. Use RGB when you need to manipulate individual channels in JavaScript or when working with Canvas/WebGL. Use HSL when building colour systems, generating shades and tints programmatically, or writing CSS that needs to be easy to reason about visually. All three formats describe exactly the same colours — the choice is purely about readability and convenience for your specific use case.

What is the difference between HSL and HSB/HSV? +
HSL (Hue, Saturation, Lightness) and HSB/HSV (Hue, Saturation, Brightness/Value) are different colour models. In HSL, 50% lightness gives the pure colour and 100% lightness is always white. In HSB, 100% brightness gives the pure colour. Design tools like Figma, Sketch, and Photoshop typically use HSB/HSV, while CSS uses HSL. The two models represent the same colours differently — a colour that looks identical may have different saturation and brightness values in HSB vs HSL.
What does the # symbol mean in HEX codes? +
The # (hash or pound) symbol is simply a prefix that tells browsers and parsers that the following six characters are a hexadecimal colour code. It has no mathematical meaning itself. Without the #, the browser would not know whether "F97316" is a colour code or some other identifier.
Why do some HEX codes have 8 characters? +
8-character HEX codes include an alpha (transparency) channel as the final two characters. For example, #F97316CC has FF=100% opacity at one end and 00=0% opacity at the other. CC equals 204 in decimal, which divided by 255 gives approximately 80% opacity. 8-character HEX alpha is supported in all modern browsers but was not supported in older versions of Internet Explorer.
How do I convert a colour to CSS Custom Properties? +
With HSL, you can split the values into separate custom properties for maximum flexibility: --color-hue: 24; --color-sat: 95%; --color-light: 53%; Then reference them with hsl(var(--color-hue), var(--color-sat), var(--color-light)). This pattern allows you to create tints by overriding just --color-light and dark mode variants by adjusting --color-light in a @media (prefers-color-scheme: dark) block.
What is OKLCH and should I use it? +
OKLCH is a newer perceptually uniform colour space standardised in CSS Color Level 4. Unlike HSL where equal numeric differences do not correspond to equal perceived differences, OKLCH is designed so that colours with the same lightness actually appear equally bright to human eyes. It is supported in all modern browsers and is increasingly recommended for design systems. This tool focuses on HEX/RGB/HSL which remain the most widely used formats.