Free · no sign-up · runs in your browser
Convert HEX to RGB and HSL
Type a 3-digit or 6-digit HEX color code (with or without `#`) or enter Red, Green and Blue values from 0 to 255. The color swatch and copyable HEX, RGB and HSL strings update as you type.
How do I convert a HEX color code to RGB?
Paste or type a 3-digit or 6-digit HEX code (such as `#1a2b3c` or `abc`) into the HEX box above. The R, G and B channel inputs, the color swatch, and the copyable `rgb(r, g, b)` and `hsl(h, s%, l%)` lines update right away. You can also type 0–255 into the R, G and B boxes to convert RGB back to HEX.
How it works
01
Enter a HEX code or RGB channels
Type a 3-digit (`#abc`) or 6-digit (`#1a2b3c`) hexadecimal code into the HEX field, or enter numbers from 0 to 255 into the R, G and B boxes.
02
Check the live color swatch
The 72×72 px swatch next to the inputs shows the exact sRGB color while all three color notations stay in sync.
03
Copy HEX, RGB or HSL
Click the copy button beside HEX (`#rrggbb`), RGB (`rgb(r, g, b)`) or HSL (`hsl(h, s%, l%)`) to copy that CSS string to your clipboard.
How HEX and RGB represent the same sRGB color
Both HEX and RGB describe a color by its Red, Green and Blue channel intensities on a scale from 0 (none) to 255 (full brightness). A 6-digit HEX code writes those three numbers as three two-digit base-16 (hexadecimal) pairs: the first two digits are Red, the middle two are Green, and the last two are Blue. For example, in `#1a2b3c`, `1a` in hex is 26 in decimal, `2b` is 43, and `3c` is 60, giving `rgb(26, 43, 60)`.
A 3-digit shorthand HEX code such as `#abc` expands by doubling each digit to `#aabbcc` before converting. The tool accepts uppercase or lowercase hex digits with or without a leading `#`, and clamps manual R, G and B entries to whole integers between 0 and 255.
Why HSL is included alongside RGB
While HEX and RGB match how screens mix light, HSL expresses the same color as Hue (0° to 359° around the color wheel), Saturation (0% gray to 100% full color) and Lightness (0% black, 50% pure hue, 100% white). The tool rounds hue to whole degrees and saturation and lightness to whole percentages.
Copying the `hsl(...)` string makes it much easier to build lighter hover states, darker borders or muted backgrounds in CSS simply by nudging the percentage values.
What this tool does not do
It does not convert 4-digit or 8-digit HEX codes with an alpha channel (`#rrggbbaa`), CMYK print values, or wide-gamut `display-p3` / `oklch` CSS strings, and you cannot type directly into the HSL readout.
Keep exploring
Related free tools
Questions
HEX to RGB: FAQ
Can I convert RGB back to HEX on this page?
Yes. Type any integer from 0 to 255 into the R, G and B number fields and the HEX input, swatch and copyable `#rrggbb` row update immediately.
Does the HEX input accept 3-digit codes or missing # symbols?
Yes. You can enter `1a2b3c`, `#1a2b3c`, `abc` or `#ABC`. Three-digit codes are doubled per channel (`abc` becomes `#aabbcc`), and the copyable HEX row always formats the result as lowercase `#rrggbb`.
Why did my HEX code show an error?
The parser requires either 3 or 6 hexadecimal characters (`0–9` and `a–f`). An 8-digit code with alpha (like `#1a2b3c80`) or a string with non-hex letters will show a message asking for 3 or 6 hex digits.
What happens if I type a number above 255 in R, G or B?
Each RGB channel is rounded and clamped to the valid 8-bit range of 0 to 255.
Does this page send my data anywhere?
All color math runs in your browser. The page sends a usage event to Google Analytics once when you use the converter, without recording the color values you type.