HEX to RGB Converter

Paste a HEX color code to get its RGB, RGBA and HSL values, or paste an rgb(), rgba() or hsl() color to get the HEX code. Short #RGB codes and 8-digit #RRGGBBAA codes with transparency are supported, and a live swatch, a color picker and an opacity slider let you fine-tune the color before copying the CSS. Everything runs in your browser.

100%
–Red
–Green
–Blue
–Alpha
HEX–
HEX with alpha (8-digit)–
Short HEX–
RGB–
RGBA–
HSL–
HSLA–

Runs entirely in your browser. Nothing you enter is uploaded or stored.

Rate this tool

Be the first to rate this tool

How to use the HEX to RGB Converter

  1. Type or paste a color: a HEX code like #3B82F6, an rgb() or rgba() value, or an hsl() value.
  2. Or click the color square to choose a color with your device’s color picker.
  3. Drag the opacity slider if you need transparency.
  4. Copy the HEX, RGB, RGBA, HSL or HSLA value you need, or copy them all at once.

How HEX color codes map to RGB

Screens build every color from red, green and blue light, each with a level from 0 to 255. A HEX color code writes those three levels in base 16, two digits each. In #3B82F6, the first pair 3B is red, 82 is green and F6 is blue. Converting each pair to decimal gives 3 × 16 + 11 = 59, 8 × 16 + 2 = 130 and 15 × 16 + 6 = 246, so the color is rgb(59, 130, 246). Going the other way, you divide each RGB value by 16 to get the two hex digits. HEX codes are not case-sensitive, so #3b82f6 and #3B82F6 are the same color.

Short HEX, 8-digit HEX and transparency

A 3-digit code such as #F80 is shorthand where each digit is doubled, so it means #FF8800. A short code is only possible when both digits of every pair match, which is why the Short HEX row sometimes says it is not available. Modern browsers also accept 4-digit and 8-digit codes, where the last digit or pair is the alpha channel, the opacity. In #3B82F680, 80 in hex is 128 out of 255, about 50% opacity.

The same transparency is written as the fourth value of rgba(), as a decimal from 0 to 1. This converter reads alpha from 8-digit HEX, rgba() and hsla() input, and the opacity slider lets you set it directly. The checkerboard behind the swatch shows how see-through the color is.

RGB versus HSL

HSL describes the same colors in a way that is easier for people to adjust. Hue is the position on the color wheel from 0 to 360 degrees, where 0 is red, 120 is green and 240 is blue. Saturation is how vivid the color is, from gray at 0% to full color at 100%. Lightness runs from black at 0% through the pure color at 50% to white at 100%. To make a lighter version of a brand color for a hover state, you can keep the hue and saturation and raise the lightness. HSL values here are rounded to whole numbers, which is how they are usually written in CSS, so converting back can shift a channel by one step.

Using the values in CSS

All of these formats work in CSS: color: #3B82F6;, background: rgb(59, 130, 246); or border-color: hsl(217, 91%, 60%);. Use rgba() or 8-digit HEX for overlays and shadows. The converter also accepts the newer space-separated syntax, such as rgb(59 130 246 / 50%), and percentage channels. For other front-end conversions, try the PX to REM converter, tidy design tokens with the JSON formatter, or embed a small image as a data URL with the Base64 encoder.

Examples

  • #3B82F6 → rgb(59, 130, 246), hsl(217, 91%, 60%)
  • #F80 → #FF8800 → rgb(255, 136, 0)
  • #00000080 → rgba(0, 0, 0, 0.5)
  • rgb(255, 255, 255) → #FFFFFF
  • hsl(0, 100%, 50%) → #FF0000

HEX to RGB Converter FAQ

How do I convert HEX to RGB by hand?

Split the code into three pairs and convert each from base 16 to base 10. For #FF8800: FF = 255, 88 = 136 and 00 = 0, so it is rgb(255, 136, 0).

What does an 8-digit HEX code mean?

The first six digits are the color and the last two are the alpha, or opacity, from 00 (fully transparent) to FF (fully opaque). #FF000080 is red at about 50% opacity.

Why does my color look different after converting to HSL and back?

HSL values are rounded to whole numbers, so a channel can move by one step out of 255. The difference is too small to see, but the HEX code can change slightly.

Can I convert RGB to HEX here too?

Yes. Paste an rgb() or rgba() value, or just three numbers like 59, 130, 246, and the HEX code appears in the results.

Does the color picker support transparency?

Browser color pickers only choose solid colors. Use the opacity slider to add transparency to any picked color.

Related tools

All Developer Tools
JSON Formatter & ValidatorBeautify, minify and validate JSON with clear error messages.Base64 Encode / DecodeEncode or decode Base64 for text and files, UTF-8 safe.Compare Two ListsFind differences, common items, and unique entries between two text lists.Cron Expression GeneratorBuild cron schedules with simple menus, or paste any cron expression to explain it in plain English and see the next 5 run times.Diff CheckerCompare two texts and see every added, removed and changed line, with word or character highlights, side by side or unified.JSON to CSVConvert a JSON array to CSV with nested objects flattened into dot-named columns, comma, semicolon or tab delimiters and a live preview.JSON to ExcelConvert a JSON array to a real Excel .xlsx spreadsheet or CSV, with nested objects flattened into dot-named columns and a live preview.PX to REM ConverterConvert pixels (px) to rem and rem to px with custom root font size and CSS table.Regex TesterTest JavaScript regular expressions live: highlighted matches, capture and named groups, indices, flags and a replace preview.Unix Timestamp ConverterSee the current Unix epoch time live, convert timestamps in seconds, milliseconds or microseconds to dates, and dates back to timestamps.URL Decode & EncodeDecode or encode URLs and query strings (percent-encoding), with + as space option and a query parameter table.Loan CalculatorWork out the monthly payment, total interest and payoff date for any loan in seconds.Text to Slug ConverterTurn titles into clean, SEO-friendly URL slugs.