UseToolSuite UseToolSuite

Color Converter

Whether to author colors in HSL or HEX, what OKLCH and the new CSS color spaces buy you, and why averaging RGB values mixes colors wrong.
Standard / Spec
W3C CSS Color Module Level 4
Execution
100% Client-Side
Privacy Level
Zero Data Stored
License / Cost
Free / No Account

Color Picker

Pick a color to convert

Color model comparison: HEX, RGB, HSL, and OKLCH

Format Syntax Best for Alpha
HEX#3b82f6Design specs, compact notation#3b82f680
RGBrgb(59, 130, 246)Programmatic manipulationrgba(59, 130, 246, 0.5)
HSLhsl(217, 91%, 60%)Theme generation, readable paletteshsla(217, 91%, 60%, 0.5)
OKLCHoklch(0.63 0.21 255)Perceptual uniformity, wide gamutoklch(0.63 0.21 255 / 0.5)

HSL is ideal for generating consistent design palettes because adjusting lightness and saturation is intuitive. OKLCH is the modern alternative that ensures equal perceived brightness across different hues, a 50% lightness blue and 50% lightness yellow actually look equally bright, unlike HSL.

CSS color functions and browser support

Modern CSS supports color functions beyond the traditional rgb() and hsl() notations. The color() function allows Display P3 and other wide-gamut color spaces. The color-mix() function blends two colors in any color space. The oklch() function provides perceptually uniform color manipulation. All major browsers support these functions as of 2024. When building design systems, define your base colors in OKLCH for consistent lightness scales, then use this converter to generate fallback HEX values for older tooling.

Three notations, one color

HEX, RGB, and HSL are three ways of writing the same sRGB color, converting between them changes nothing about how it displays. What changes is how easy the color is to think about:

NotationReads asBest for
HEX #FF7F50Compact RGB in hexDesign tokens, copy-paste
RGB rgb(255 127 80)Channel intensitiesProgrammatic mixing, canvas
HSL hsl(16 100% 66%)Hue / saturation / lightnessHuman tweaking, deriving variants

A 3-digit HEX like #F70 is just shorthand, each digit doubles to #FF7700. And remember HSL’s units: hue is degrees (0–360), but saturation and lightness are percentages: hsl(200, 0.8, 0.5) is wrong; it must be hsl(200, 80%, 50%).

The color-mixing trap

A subtle gotcha that bites anyone interpolating colors: you can’t correctly mix two colors by averaging their RGB values. HEX/RGB values are stored gamma-encoded in sRGB, so the naive midpoint of two colors comes out darker than it should, and a red→green blend passes through a dull gray. Correct mixing happens in linear RGB (remove gamma, mix, re-apply) or, better, in a perceptual space. Modern CSS handles this for you: color-mix(in oklch, red, blue) produces the vivid purple your eye expects instead of the muddy sRGB midpoint.

Alpha and named colors

This converter focuses on opaque colors across HEX, RGB, and HSL. To add transparency, extend the output yourself. rgb(255 0 0) → rgba(255 0 0 / 0.5), or #FF0000 → #FF000080 (the last two hex digits are alpha). For CSS named colors like coral or tomato, look up the HEX equivalent (coral = #FF7F50) and paste that in. Everything runs locally in your browser, with a live preview so you can confirm the converted value is the color you meant.

Last updated Built and maintained by Necmeddin Cunedioglu How tools are tested

How helpful was this tool?

Click to rate

Key Concepts

HEX Color Code

A six-digit hexadecimal representation of a color in the format #RRGGBB, where each pair represents the intensity of red, green, and blue channels from 00 (0) to FF (255). Shorthand notation (#RGB) expands each digit (e.g., #F00 becomes #FF0000). HEX is the most common color format in web development and design handoff.

RGB Color Model

An additive color model where Red, Green, and Blue light are combined in varying intensities (0-255 each) to produce a wide spectrum of colors. RGB is the native color model for digital screens. When all three channels are at maximum (255, 255, 255), the result is white; when all are zero, the result is black.

HSL Color Model

A cylindrical color model representing colors by Hue (0-360° on the color wheel), Saturation (0-100%, vibrancy), and Lightness (0-100%, brightness). HSL is more intuitive than RGB for human color selection, you can create tints by increasing lightness, shades by decreasing it, and tones by reducing saturation, all without affecting the base hue.

sRGB Color Space

The standard color space for the web, defined by the IEC 61966-2-1 specification. All CSS color values (HEX, RGB, HSL) are assumed to be in sRGB unless specified otherwise. sRGB covers approximately 35% of the visible color spectrum. Wider gamut spaces like Display P3 and Rec. 2020 are supported by modern CSS via the color() function.

Frequently Asked Questions

Can I convert colors with alpha transparency (RGBA/HSLA)?

This tool focuses on opaque color conversion between HEX, RGB, and HSL. For colors with transparency, you would need to add the alpha channel manually to the output, for example, changing rgb(255, 0, 0) to rgba(255, 0, 0, 0.5).

Does the tool support CSS named colors like "coral" or "tomato"?

Currently, the tool accepts HEX, RGB, and HSL input formats. To convert a named CSS color, you can look up its HEX value first (e.g., coral is #FF7F50) and then enter that into the converter.

What HEX format does the tool accept. 3-digit or 6-digit?

The tool accepts both 3-digit shorthand (e.g., #F00) and 6-digit full HEX values (e.g., #FF0000). The 3-digit format is automatically expanded to 6 digits for precise conversion.

Should I author my CSS colors in HSL or HEX?

Use HEX for fixed design tokens and HSL when you need to reason about or tweak a color in code. HEX is compact and universal, perfect for a locked brand value. But HSL exposes hue, saturation, and lightness as separate numbers, so you can derive a hover state by dropping lightness 10%, build a tint/shade ramp by stepping lightness, or desaturate without touching the hue. That's impossible to do legibly with HEX, where you'd have to recompute all three channels. A common pattern: define brand colors as HEX tokens, then manipulate them in HSL (or OKLCH) when generating variants.

What are OKLCH and the new CSS color spaces, and should I use them?

OKLCH (and OKLab) are perceptually uniform color spaces now supported across modern browsers, and they fix a real problem with HSL/RGB: equal numeric steps don't look equally different to the eye. In HSL, two colors with the same lightness value can look wildly different in brightness (yellow vs blue), which makes building consistent palettes hard. OKLCH's lightness actually matches perceived brightness, so a lightness ramp looks even, and hue shifts stay vivid instead of passing through muddy grays. Use it for generating palettes, accessible color scales, and gradient interpolation (linear-gradient(in oklch, ...)). It's production-ready today with a HEX/HSL fallback if you support very old browsers.

Related Guides

Related Tools

Embed this tool on your site

Paste this snippet into any HTML page or blog post to embed a live, fully working copy of Color Converter. Free for any use.