Color Code Converter
Enter a color in any format — HEX, RGB, or HSL — and instantly see it converted to all other formats with a live preview.
How to Use the Color Code Converter
Working with colors across different tools and platforms often means switching between HEX, RGB, and HSL formats. This converter eliminates the manual math. Enter any color value and instantly get the equivalent in all three formats along with a large preview swatch so you can visually confirm the color.
- Enter a color: Type or paste a color value in any supported format. The tool auto-detects whether it is HEX, RGB, or HSL.
- View the results: All three formats are displayed simultaneously along with a colour preview swatch.
- Copy any format: Click the copy button next to the format you need to place it on your clipboard.
Supported Input Formats
| Format | Examples |
|---|---|
| HEX (6-digit) | #3b82f6, 3b82f6 |
| HEX (3-digit shorthand) | #f00, f00 |
| RGB functional | rgb(59, 130, 246) |
| RGB values only | 59, 130, 246 |
| HSL functional | hsl(217, 91%, 60%) |
Understanding Color Models
HEX is the most common format in web development. It represents red, green, and blue channels as two-digit hexadecimal numbers, giving 16.7 million possible combinations. It is concise and widely supported in CSS, HTML, and design tools.
RGB (Red, Green, Blue) represents colors as three integers from 0 to 255. It maps directly to how screens display color by mixing red, green, and blue light. RGB is used in CSS, JavaScript canvas operations, and image processing libraries.
HSL (Hue, Saturation, Lightness) is a more human-friendly model. Hue is the colour angle on the colour wheel (0–360°), saturation controls vibrancy (0–100%), and lightness controls brightness (0–100%). Designers often prefer HSL because creating colour variations — like a lighter or darker shade — only requires changing the lightness value, leaving hue and saturation intact.
Color Conversion Formulas
Converting between HEX and RGB is straightforward: each pair of hex digits maps to a decimal value from 0 to 255. Converting between RGB and HSL involves normalizing RGB values to the 0–1 range, finding the minimum and maximum channels, then calculating hue based on which channel is dominant, saturation from the range between min and max, and lightness as the midpoint. This tool handles all the math for you in real time as you type, so you can focus on choosing the right colour for your project.
Frequently Asked Questions
How do I convert a HEX color to RGB?
Enter the HEX value (e.g. #3b82f6) into the input field. The tool automatically detects the format and converts it to RGB (59, 130, 246) and HSL (217°, 91%, 60%) simultaneously. You can also enter shorthand HEX codes like #f00 which expand to #ff0000.
What is the HSL color model?
HSL stands for Hue, Saturation, and Lightness. Hue is a degree on the color wheel from 0 to 360 (0 is red, 120 is green, 240 is blue). Saturation is how vivid the color is (0% is grey, 100% is full color). Lightness controls brightness (0% is black, 50% is normal, 100% is white). HSL is often preferred by designers because adjusting lightness or saturation is more intuitive than modifying individual RGB channels.
Can I enter RGB values without the 'rgb()' prefix?
Yes. The tool accepts multiple input formats: you can type rgb(59, 130, 246), or just 59, 130, 246, or even 59 130 246. It auto-detects whether your input is HEX, RGB, or HSL based on the pattern and converts it accordingly.