Color Converter (HEX to RGB & HSL)

Convert web colors from 3-digit (#RGB) or 6-digit (#RRGGBB) HEX codes into RGB (rgb(r, g, b)), HSL (hsl(h, s%, l%)), and CSS Custom Property variable syntax. Features a native color picker, a live luminance-aware preview swatch, and individual one-click Copy buttons.

#2563EBrgb(37, 99, 235)
HEX#2563EB
RGBrgb(37, 99, 235)
HSLhsl(221, 83%, 53%)
CSS Variable Format--brand-color: #2563EB;
Advertisement

How to Use Color Converter (HEX to RGB & HSL)

Click the visual color picker square or type a 6-digit (`#RRGGBB`) or 3-digit shorthand (`#RGB`, which expands each nibble such as `#26F` → `#2266FF`) hexadecimal code into the **HEX Code** input field (default `#2563EB`). The converter parses the red, green, and blue channels (`0–255`), computes the cylindrical Hue (`0–360°`), Saturation (`0–100%`), and Lightness (`0–100%`) values, and updates the top preview banner—automatically switching the preview text between dark (`#0f172a`) and white (`#ffffff`) based on relative luminance (`(0.299×R + 0.587×G + 0.114×B) ÷ 255`). Below the input, click **Copy** next to any of the four output rows: **HEX** (`#2563EB`), **RGB** (`rgb(37, 99, 235)`), **HSL** (`hsl(221, 83%, 53%)`), or **CSS Variable Format** (`--brand-color: #2563EB;`). Checking image transparency or photo metadata? Visit our Transparent Background Checker and Image Metadata Viewer.

  1. 1

    Type a HEX Code or Use the Color Picker

    Enter a 6-digit (#RRGGBB) or 3-digit (#RGB) hex string in the HEX Code field, or click the color picker swatch.

  2. 2

    Preview the Contrast-Adaptive Swatch

    Inspect the live top color banner displaying the uppercase HEX code and rgb(r, g, b) values.

  3. 3

    Compare HEX, RGB, HSL & CSS Variable Rows

    Read the converted RGB channels (0–255), HSL (degrees and percentages), and CSS Custom Property syntax.

  4. 4

    Copy Any Color Format in One Click

    Click the Copy button next to HEX, RGB, HSL, or CSS Variable Format to paste into your stylesheet.

Worked Input & Output Example

Converting Default Royal Blue (#2563EB) to RGB, HSL & CSS Variable Format

The 6-digit hexadecimal code splits into three base-16 byte pairs (25, 63, EB) before converting to RGB and HSL.

1. HEX Code Input
#2563EB (0x25 Red, 0x63 Green, 0xEB Blue)

Default 6-digit HEX code (3-digit #RGB shorthand codes are also automatically expanded).

2. HEX → RGB → HSL Math

R = 37, G = 99, B = 235 · Max = 0.922, Min = 0.145 → Hue = 221°, Saturation = 83%, Lightness = 53%.

Client-side calculation
3. 4 Copyable Output Rows
#2563EB | rgb(37, 99, 235) | hsl(221, 83%, 53%)

CSS Variable Format: --brand-color: #2563EB; · Preview text: #ffffff (luminance 0.377 ≤ 0.5).

HEX Row#2563EBAccepts #RGB or #RRGGBB
RGB Rowrgb(37, 99, 235)8-bit channels (0–255)
HSL Rowhsl(221, 83%, 53%)Hue 0–360°, Sat/Light %
CSS Variable Row--brand-color: #2563EB;One-click CSS variable copy

Related Free Tools

Explore more browser-based tools in Daily & Text Utilities or browse the complete All Tools Directory.