Hex to RGB Converter – Convert Hex Color Codes

Convert Hex Colors to RGB (and Back)

This free hex to RGB converter turns a hex color code like #3498db into its RGB values, and converts RGB back to hex — with a live color swatch so you can see the exact shade. It is built for designers and developers who jump between CSS, design tools, and image editors that expect different color formats.

How to Use the Converter

  1. Choose Hex → RGB or RGB → Hex.
  2. Enter your hex code (with or without the #) or your three RGB values (0–255).
  3. Press Convert to get the result and a color preview.

How Hex and RGB Colors Work

An RGB color mixes red, green, and blue light, each on a scale from 0 to 255. A hex code is the same thing written in base-16: two hex digits each for red, green, and blue. For example, #3498db breaks into 34, 98, and db in hex, which equal 52, 152, and 219 in decimal — so the RGB value is rgb(52, 152, 219).

How to Convert Hex to RGB by Hand

Split the six-digit hex code into three pairs (RR, GG, BB) and convert each pair from base-16 to a number from 0–255. To go the other way, convert each RGB value to a two-digit hex number and join them with a leading #. Three-digit shorthand like #fff expands to #ffffff.

Common Color Conversions

Hex RGB
#000000 rgb(0, 0, 0)
#ffffff rgb(255, 255, 255)
#ff0000 rgb(255, 0, 0)
#3498db rgb(52, 152, 219)

Why Convert Between Hex and RGB?

CSS and design handoffs often mix formats: a brand guide might list hex codes while a gradient or rgba() value needs RGB. Converting accurately keeps colors consistent across your website, graphics, and UI, and RGB is required whenever you add transparency with rgba(). Having both values on hand saves time and prevents the slightly-off colors that creep in from eyeballing shades.

Frequently Asked Questions

How do I convert hex to RGB?

Split the hex into red, green, and blue pairs and convert each from base-16. #3498db = rgb(52, 152, 219). The tool above does it instantly.

How do I convert RGB to hex?

Convert each 0–255 value to two hex digits and join with a #. rgb(52, 152, 219) = #3498DB.

Is the hex to RGB converter free?

Yes — free, browser-based, with a live color preview and no signup.


RGB, RGBA, and Opacity

RGB describes a solid color, but the web often needs transparency too. That is where rgba() comes in — the same red, green, and blue values plus an alpha channel from 0 (fully transparent) to 1 (fully opaque). Once you have converted a hex code to RGB, building an rgba() value is easy: take rgb(52, 152, 219) and add an alpha, for example rgba(52, 152, 219, 0.5) for a half-transparent overlay. Hex cannot express opacity in older syntax, which is one of the main reasons designers convert to RGB.

Shorthand Hex Codes

You will often see three-digit hex codes like #fff or #09c. These are shorthand: each digit is doubled, so #fff is the same as #ffffff (white) and #09c expands to #0099cc. The converter accepts both the three-digit and six-digit forms and expands the shorthand automatically before giving you the RGB value.

Keeping Brand Colors Consistent

Brand guidelines usually specify exact colors, and a one-digit slip turns the right blue into the wrong one. Converting from a single source of truth — whether that is a hex code from a style guide or RGB values from a design file — keeps your website, graphics, emails, and app perfectly aligned. The live swatch above lets you confirm the shade visually before you commit it to code.

Color, Contrast, and Accessibility

Once you have a color in RGB, you can check it against accessibility guidelines. Web Content Accessibility Guidelines (WCAG) recommend a contrast ratio of at least 4.5:1 between text and its background for normal text. RGB values are the starting point most contrast checkers use, so converting your hex codes is the first step to confirming your color choices are readable for everyone. Keeping a record of both the hex and RGB versions of your palette makes it quick to test combinations and to drop the right value into CSS, design tools, or a contrast checker.

More Free Online Tools

Number Base Converter · Image Compressor · All free tools