tooldeb Online Tools
Categories
Finance & Investing Interest, savings, returns, and inflation. Loans & Property Mortgages, repayment, DSR/DTI/LTV, and jeonse. Tax & Payroll Take-home pay, severance, insurance, and taxes. Shopping & Pricing Discounts, tips, unit price, and margins. Health & Fitness Body metrics, nutrition, and training. Math Percentages, fractions, algebra, and sequences. Geometry Area, volume, and surface of plane and solid shapes. Statistics & Probability Averages, spread, combinations, and odds. Unit Conversion Length, weight, temperature, pressure, and more. IT & Digital Data size, screens, color, and network speed. Engineering & Electronics Circuits, resistance, PCB, and signals. Date & Time Ages, D-day, date math, and time zones. Home & Interior Paint, tile, wallpaper, flooring, and concrete. Automotive Fuel cost, economy, tires, and vehicle tax. Everyday Bills, delivery, photos, and odds and ends.
EN
한국어 English

RGB to HEX & HSL Color Converter

Enter RGB values (0–255) to instantly get the matching HEX code and HSL value.

Inputs
HEX
#4F46E5
RGB(79, 70, 229)
HSL
hsl(243, 75%, 59%)
Values are clamped to the valid RGB range of 0–255 and rounded to whole numbers before conversion.

How RGB converts to HEX and HSL

HEX simply re-encodes each RGB channel (0–255) as a 2-digit base-16 number. HSL re-describes the same color by hue (0–360°), saturation, and lightness (both in %), which are derived from the highest and lowest of the three channels.

HEX = #RRGGBB (each channel in base 16) L = (max + min) / 2 S = (max − min) / (1 − |2L − 1|) H depends on which channel is highest
  • R,G,B — red, green, blue channels, 0–255 each
  • H — hue, 0–360°
  • S, L — saturation and lightness, 0–100%

More detail

Why HEX uses two digits per channel

A single base-16 digit only covers 0–15, but an RGB channel goes up to 255. Two hex digits cover 0–255 exactly (16 × 16 = 256), which is why the full form of a color code is 6 hex digits — two each for red, green, and blue. CSS also accepts a 3-digit shorthand, but only when each pair repeats the same digit (#FF0000 → #F00).

Quick check. rgb(79, 70, 229) — a common indigo/violet — converts to #4F46E5 in hex and roughly hsl(243, 75%, 59%).

Frequently asked questions

What is rgb(79, 70, 229) in hex?

#4F46E5. Each channel converts to hex separately: 79 → 4F, 70 → 46, 229 → E5.

What is rgb(79, 70, 229) in HSL?

Roughly hsl(243, 75%, 59%) — a blue-violet hue with high saturation and mid-high lightness.

What's the difference between HEX and HSL?

HEX packs the red, green, and blue channels (0–255 each) into a 6-digit base-16 code. HSL describes the same color differently — as a hue angle (0–360°) plus saturation and lightness percentages — which is often more intuitive for adjusting a color by eye.

What happens if I enter a value above 255 or below 0?

The calculator clamps it to the valid range first — anything above 255 becomes 255, anything below 0 becomes 0 — since RGB channels only exist between 0 and 255.

Why do black and white have no hue?

Black (0,0,0) and white (255,255,255) are achromatic — all three channels are equal, so there's no dominant channel to derive a hue from, and both show hue as 0 by convention.

Related calculators

Browse all Digital calculators