$ man rgb-to-hex-converter
RGB to HEX Converter
NAME
rgb-to-hex-converter — Convert RGB to HEX and back, plus HSL and HSV, with a live swatch, alpha support and a copy button on every format. Shows contrast against black and white.
SYNOPSIS
# What is a RGB to HEX converter?
An RGB to HEX converter turns red, green and blue channel values into a hexadecimal colour code and back, and also converts between HEX, RGB, HSL and HSV so the same colour can be written in whichever notation a tool expects.
WHY HERE
Number-base and data utilities for developers working with APIs.
rgb(14, 107, 89)
| Format | Value | |
|---|---|---|
| HEX | #0e6b59 | |
| HEX uppercase | #0E6B59 | |
| RGB | rgb(14, 107, 89) | |
| RGB, space syntax | rgb(14 107 89) | |
| HSL | hsl(168, 76.9%, 23.7%) | |
| HSV / HSB | hsv(168, 86.9%, 42%) | |
| Channels | R 14 G 107 B 89 |
HSL and HSV are different models, not different names. Lightness 100% in HSL is white; value 100% in HSV is the brightest version of the hue. Figma and Photoshop show HSV, labelled HSB.
Body text passes WCAG AA on this colour in white (needs 4.5:1).
USAGE
01 → Paste any format
Hex with or without the hash, rgb() or hsl() in comma or space syntax, hsv/hsb, a CSS keyword, or three bare numbers. The tool works out which you gave it.
02 → Adjust with the sliders
The channel sliders and the hue, saturation and lightness sliders drive the same colour, so you can enter in one model and tune in another.
03 → Copy the format you need
Each row has its own copy button. The shorthand hex row appears only when it is lossless, because #f0a is not always the same colour as #ff00aa.
04 → Check the contrast before using it for text
The contrast figures against white and black are WCAG ratios. Body text needs 4.5:1 and large text 3:1, so a mid-tone brand colour often fails both.
DESCRIPTION
A hex colour code is RGB written in base sixteen. #FF00AA is three pairs of hex digits, one per channel: FF is 255, 00 is 0, AA is 170, so the colour is rgb(255, 0, 170). Converting RGB to hex is therefore just writing each channel in base sixteen and padding it to two digits; converting back is reading each pair. That is why the shorthand form works at all — #F0A expands to #FF00AA because each digit is doubled — and also why the shorthand is only available for colours whose channel pairs happen to repeat. An eight-digit hex code adds a fourth pair for alpha, where 00 is transparent and FF is opaque.
HSL and HSV are not the same model with different letters, and confusing them is the commonest mistake in this area. Both use the same hue angle, 0 to 360 degrees round the colour wheel. But HSL puts white at lightness 100% and the pure hue at 50%, while HSV puts white at saturation 0% with value 100% and the pure hue at saturation 100%, value 100%. So hsl(0 100% 50%) and hsv(0 100% 100%) are both pure red, hsl(0 100% 100%) is white, and hsv(0 100% 50%) is a dark red. CSS speaks HSL; Photoshop and Figma show HSB, which is HSV under another name. Converting between them has to go through RGB, which this tool does.
The contrast figures are worth more attention than the codes. WCAG relative luminance weights green far above blue — 0.7152 against 0.0722 — because the eye is far more sensitive to green light. That means two colours with the same HSL lightness can have wildly different readability: a saturated yellow at 50% lightness is bright enough that black text works and white does not, while a saturated blue at the same lightness is the other way round. The ratios shown here are the actual WCAG calculation, so a value of 4.5 or above means body text passes AA on that background and 3.0 means large text does.
FAQ
## How do I convert RGB to hex?
Write each channel in base sixteen and pad to two digits. 255 is FF, 0 is 00, 170 is AA, so rgb(255, 0, 170) is #FF00AA.
## What is #FFFFFF in RGB?
rgb(255, 255, 255) — white. FF is the largest two-digit hex number, 255, and all three channels at maximum is white.
## Is #F0A the same as #FF00AA?
Yes. Three-digit hex doubles each digit, so #F0A expands to #FF00AA. But most colours cannot be written in three digits at all — #FE00AA has no shorthand.
## What is the difference between HSL and HSV?
Where white lives. In HSL, lightness 100% is white and the pure hue is at 50%. In HSV, white is saturation 0% with value 100%, and the pure hue is at saturation and value both 100%. Photoshop's HSB is HSV.
## How does the eight-digit hex code work?
The fourth pair is alpha: #FF00AA80 is the same pink at 50% opacity, because 80 in hex is 128, which is half of 255. It is supported in every current browser.