utilduck
Home · Developer · Color Converter

Color Converter

Enter a HEX color code to instantly see the RGB and HSL equivalents with a color preview.

Color preview
RGB
-
HSL-
HEX color-

About color formats

Colors on screens are commonly expressed in three formats. HEX uses a six-digit hexadecimal code such as #4f46e5. RGB (Red, Green, Blue) describes the same color as three numbers from 0 to 255. HSL (Hue, Saturation, Lightness) expresses color by its angle on the color wheel (0-360°), its purity (0-100%), and its brightness (0-100%). All three describe the same color space and are interconvertible.

How do I convert HEX to RGB and HSL?

To convert a HEX color to RGB, split it into three 2-digit pairs and convert each from hexadecimal to decimal (0-255); to get HSL, calculate hue, saturation, and lightness from those RGB values. Example: #4F46E5 converts to rgb(79, 70, 229) and hsl(243, 75%, 59%).

Steps to convert HEX to RGB and HSL

  1. Remove the # symbol and split the 6-digit HEX code into three 2-digit pairs (for #4F46E5: 4F, 46, E5).
  2. Convert each hexadecimal pair to a decimal number from 0 to 255 (4F=79, 46=70, E5=229) to get the RGB values.
  3. Divide each RGB value by 255 to normalize it to a 0-1 range, then find the maximum and minimum of the three.
  4. Lightness is the average of the max and min; saturation and hue are calculated from the difference between max and min using standard HSL formulas.
  5. Round hue to whole degrees (0-360) and saturation and lightness to whole percentages (0-100%) for display.

HEX to RGB to HSL

RGB channel = parseInt(hex pair, 16) · Lightness = (max(R,G,B) + min(R,G,B)) / 2, normalized 0-1
  • R, G, B = red, green, blue channel values, each 0-255
  • H, S, L = hue in degrees (0-360), saturation and lightness in percent (0-100%)

Common color conversions

What is #FF0000 in RGB?

#FF0000 is rgb(255, 0, 0) — pure red, with the red channel at its maximum and green and blue at zero.

What is #FFFFFF in RGB?

#FFFFFF is rgb(255, 255, 255) — pure white, with all three channels at their maximum.

What is #000000 in RGB?

#000000 is rgb(0, 0, 0) — pure black, with all three channels at zero.

What is rgb(0, 128, 0) in hex?

rgb(0, 128, 0) is #008000 — a medium green, since 128 in decimal is 80 in hexadecimal.

What is #FFA500 in RGB?

#FFA500 is rgb(255, 165, 0) — standard orange.

What is #00FF00 in RGB?

#00FF00 is rgb(0, 255, 0) — pure green, with only the green channel at its maximum.

What is #0000FF in RGB?

#0000FF is rgb(0, 0, 255) — pure blue, with only the blue channel at its maximum.

What is rgb(255, 255, 0) in hex?

rgb(255, 255, 0) is #FFFF00 — pure yellow, mixing full red and full green.

Example color conversions

HEXRGBHSL
#4F46E5rgb(79, 70, 229)hsl(243, 75%, 59%)
#FF0000rgb(255, 0, 0)hsl(0, 100%, 50%)
#00FF00rgb(0, 255, 0)hsl(120, 100%, 50%)
#1D4ED8rgb(29, 78, 216)hsl(224, 76%, 48%)
#FFFFFFrgb(255, 255, 255)hsl(0, 0%, 100%)

Frequently asked questions

What is the difference between HEX, RGB, and HSL?

HEX and RGB describe a color the same way, as red, green, and blue light amounts, just in different notations (base-16 vs base-10). HSL describes the same color by hue (the color itself), saturation (intensity), and lightness (how light or dark), which is often more intuitive for adjusting a color by hand.

Why does white show 0% saturation?

Saturation measures how far a color is from gray. Pure white, black, and every shade of gray in between have equal red, green, and blue values, so their saturation is always 0%, regardless of lightness.

Can I enter a 3-digit HEX code like #FFF?

This tool expects the full 6-digit HEX format (#RRGGBB). A 3-digit shorthand like #FFF is CSS shorthand for #FFFFFF, where each digit is doubled; expand it to 6 digits before entering it here.

How is hue calculated when red, green, and blue are all different?

Hue depends on which channel, red, green, or blue, has the highest value, and is calculated from the relative position of the other two channels. The result is an angle on a 360-degree color wheel, where 0 degrees is red, 120 is green, and 240 is blue.

This tool converts standard 6-digit HEX colors used on the web; it does not support alpha (transparency) channels, named CSS colors, or color spaces beyond sRGB such as HSV or LAB.

Sources: W3C CSS Color Module Level 4

Privacy and safety

  • Runs in your browser — Everything you type is calculated on your own device. Your inputs are never sent to a utilduck server.
  • Encrypted connection — Pages are served over HTTPS, so nobody on the network can read what you load.
  • Not shared with third parties — Your inputs are not passed to analytics or advertising services.
  • Nothing is stored — Results are not saved to any server, and there is no account to create.

Last updated: 2026-08-17