PlayTools

HEX, RGB, HSL: one source of truth for design tokens

Convertissez instantanément les couleurs entre HEX, RGB, HSL et HSB. Avec sélecteur de couleur visuel.

Runs in your browser — nothing you enter is uploaded

Click to pick

HEX#6366f1
RGBrgb(99, 102, 241)
HSLhsl(239, 84%, 67%)

HEX, RGB, HSL: one source of truth for design tokens

Converting between cylindrical (HSL) and cube-root models helps when a design system stores tokens in HEX but animation tweens in HSL for perceptual smoothness.

Gamut differences between displays mean on-screen matches are approximate; print workflows need CMYK profiles not covered here.

HEX, RGB and HSL describe the same colour

All three formats specify a colour in the sRGB colour space used by browsers. HEX is RGB written in base 16: #6366F1 means red 0x63 = 99, green 0x66 = 102 and blue 0xF1 = 241, so it is identical to rgb(99, 102, 241). HSL re-expresses the same colour as hue (an angle around the colour wheel, 0–360°), saturation and lightness (0–100%) — here hsl(239, 84%, 67%).

The converter accepts six-digit hex codes and the three-digit CSS shorthand, in which each digit is doubled: #FFF is #FFFFFF and #3A7 is #33AA77. Upper and lower case are equivalent.

Why HSL values do not always round-trip

HSL is shown in whole degrees and percentages, which is coarser than RGB. Converting #6366F1 to hsl(239, 84%, 67%) and back gives #6467F2 — one step brighter in each channel. The difference is invisible, but if you are matching a brand colour exactly, keep the HEX value as the source of truth and use HSL only for adjustments.

Using HSL to build a palette

  • Lighter and darker shades: keep hue and saturation, change lightness — hsl(239, 84%, 90%) for a background tint, hsl(239, 84%, 40%) for hover states.
  • Muted versions: lower the saturation while keeping hue and lightness.
  • Complementary colour: add 180° to the hue. Triadic colours sit 120° apart, analogous colours 30° either side.
  • Equal HSL lightness does not mean equal perceived brightness: yellow at 50% looks much lighter than blue at 50%. Check contrast rather than trusting the L value.

Checking text contrast

The Web Content Accessibility Guidelines (WCAG 2) require a contrast ratio of at least 4.5:1 for normal text and 3:1 for large text (about 24 px, or 19 px bold). Indigo #6366F1 on white measures 4.47:1 — just short for body text, though fine for large headings and buttons. A slightly darker #4F46E5 reaches 6.29:1. For neutral greys, #767676 is the lightest that passes 4.5:1 on white.

Screen and print

HEX, RGB and HSL describe light from a screen. Printing uses CMYK inks with a smaller range of reproducible colours, so very saturated screen colours — bright blues and greens especially — print duller. Ask your printer for their colour profile, or specify a Pantone reference, when an exact printed match matters.

Modern CSS colour syntax

Current CSS accepts space-separated values with an optional alpha after a slash — rgb(99 102 241 / 50%) and hsl(239 84% 67% / 0.5) — alongside the comma forms this tool outputs. Eight-digit hex adds alpha as the last two digits (#6366F180 is about 50% opacity); this converter works with opaque colours, so drop those two digits before pasting. Newer spaces such as oklch() describe colours more evenly for the eye and can reach wider-gamut displays, but HEX and RGB remain the common currency of design tools.

These free tools pair well with this page — open them in a new tab to finish your workflow.

Questions fréquentes

Quelle est la différence entre HEX, RGB et HSL ?

HEX est une notation hexadécimale à 6 chiffres (ex. #ff6600) couramment utilisée en CSS et dans les outils de design. RGB spécifie les canaux rouge, vert et bleu en entiers de 0 à 255. HSL décrit une couleur par sa teinte (0–360°), saturation (0–100%) et luminosité (0–100%), plus intuitif pour les humains.

Comment convertir HEX en RGB ?

Divisez la valeur HEX en trois paires : la première est le rouge, la deuxième le vert, la troisième le bleu. Convertissez chaque paire de l'hexadécimal en décimal. Par exemple, #1a2b3c → R=0x1a=26, G=0x2b=43, B=0x3c=60, soit RGB(26, 43, 60).

Que signifie l'opacité / alpha ?

L'alpha est un quatrième canal (0–1 ou 0–100%) qui contrôle la transparence. Un alpha de 0 est totalement transparent, 1 (ou 100%) totalement opaque. En CSS, cela s'exprime avec rgba() ou hsla(), ou en HEX 8 chiffres comme #rrggbbaa.

Pourquoi ma couleur paraît-elle différente à l'écran et à l'impression ?

Les écrans utilisent la synthèse additive RVB — rouge + vert + bleu = blanc. Les imprimantes utilisent la synthèse soustractive CMJN — cyan + magenta + jaune + noir = noir. Les profils colorimétriques et les gammes de couleurs diffèrent selon les appareils.

Qu'est-ce que la gamme de couleurs ?

La gamme de couleurs est l'ensemble des couleurs qu'un appareil peut reproduire. sRGB est la norme web la plus répandue. Les écrans à large gamme (DCI-P3, Rec. 2020) peuvent afficher des couleurs plus vives. Les couleurs hors gamme sont écrêtées ou réduites en tons.

Comment trouver la couleur complémentaire d'une couleur ?

La couleur complémentaire est directement opposée sur le cercle chromatique. En HSL, ajoutez simplement 180° à la valeur de teinte. Par exemple, une couleur de teinte 60° (jaune) a pour complémentaire la teinte 240° (bleu).

Les codes couleur HEX sont-ils sensibles à la casse ?

Non. #FF6600 et #ff6600 sont identiques. CSS traite les codes HEX sans distinction de casse. Cependant, de nombreux développeurs et guides de style préfèrent les minuscules pour la cohérence.