Hex to RGB Converter

Free hex to RGB converter. Convert a hex color code to RGB and HSL values, with a live color swatch preview. Supports 3- and 6-digit hex.

AI-ready Use this tool with AI

This tool has a free JSON API. Copy a prompt or skill below to use it with ChatGPT, Claude, or any AI agent — no API key needed.

API docs
Enter a hex color above.

How hex to rgb converter works

Colors on the web are usually written as a hex code, which packs the red, green, and blue channel values into six hexadecimal digits (two per channel). Each pair ranges from 00 to FF, which is 0 to 255 in decimal. The shorthand #rgb expands each digit into a pair (e.g. #4f8 → #44ff88).

This converter parses the hex into its three decimal channel values, formats them as rgb(), and also computes the HSL (hue, saturation, lightness) representation. HSL is often easier for designers because hue, saturation, and lightness map to how people think about color. The conversion follows the standard algorithm based on the maximum and minimum channel.

Type a hex code with or without the leading #. The converter accepts 3- and 6-digit forms and shows a live swatch so you can confirm the color. Use the result to copy rgb() or hsl() values directly into CSS, or to match a color between design tools that use different formats.

Frequently asked questions

How do I convert hex to RGB?
Split the 6-digit hex into three 2-digit pairs and convert each from base 16 to decimal. #4f8cff becomes rgb(79, 140, 255) because 4f=79, 8c=140, and ff=255. This converter does it automatically and accepts the 3-digit shorthand too.
What is the difference between RGB and HSL?
RGB lists the raw red, green, and blue intensities. HSL describes the same color as hue (angle on the color wheel), saturation (intensity), and lightness, which is often more intuitive for picking and adjusting colors. This tool gives you both.
Does it accept the 3-digit shorthand?
Yes. #fff is treated as #ffffff, and #4f8 as #44ff88 — each digit is doubled. Both produce the same result as the expanded 6-digit form.
Can I use it without the leading hash?
Yes. The leading # is optional, so "4f8cff" works the same as "#4f8cff". The output always includes the normalized lowercase hex.