Home › Image Tools › RGB to HEX

RGB to HEX

Convert any RGB color to its HEX code instantly. Drag the sliders, type the numbers or paste a value like rgb(12, 34, 56), and copy the HEX, HSL or ready-made CSS with one click.

Last updated:

Also accepts rgba(), percentages and HEX codes.

#1E90FF
HEX#1E90FF
Short HEX–
RGB
HSL
CSS
Advertisement

Common colors Click a color to load it

Advertisement

How to use the RGB to HEX

  1. Enter your RGB values with the sliders or the number boxes (0 to 255 each).
  2. Or paste a value such as rgb(12, 34, 56), 12,34,56 or 12 34 56 and press Convert.
  3. Read the HEX code on the swatch and in the results. Tick Lowercase HEX if you prefer #1e90ff.
  4. Add transparency with Include alpha to get an 8-digit HEX like #1E90FF80.
  5. Press Copy next to HEX, RGB, HSL or the CSS variable to use it in your code or design app.

RGB to HEX formula

HEX is the same RGB color written in base 16. Each channel from 0 to 255 becomes two hex digits from 00 to FF: divide the value by 16, the whole number is the first digit and the remainder is the second. The digits 10 to 15 are written A to F.

Worked example: rgb(12, 34, 56). 12 ÷ 16 = 0 remainder 12, so 0C. 34 ÷ 16 = 2 remainder 2, so 22. 56 ÷ 16 = 3 remainder 8, so 38. Together that gives #0C2238.

Decimal01751102128153204255
HEX001133668099CCFF

Alpha values in 8-digit HEX

With transparency, a fourth pair is added at the end: alpha × 255, rounded and written in hex. Here are common opacity levels.

Opacity100%90%75%50%25%10%0%
HEX suffixFFE6BF80401A00

Picking readable text colors

The swatch shows the contrast ratio of your color against white and black text, using the WCAG formula. A ratio of at least 4.5:1 is recommended for normal body text and 3:1 for large headings. The swatch automatically uses whichever text color reads better. To go the other way, from a HEX code to RGB values, use HEX to RGB, and for print colors try RGB to CMYK.

Frequently asked questions

How do I convert RGB to HEX?

Convert each of the red, green and blue values (0 to 255) to a two-digit hexadecimal number and join them after a # sign. For rgb(30, 144, 255): 30 is 1E, 144 is 90 and 255 is FF, so the HEX code is #1E90FF.

What is the HEX code for rgb(255, 255, 255)?

rgb(255, 255, 255) is pure white, which is #FFFFFF in HEX, or #FFF in short form. rgb(0, 0, 0) is black, #000000 or #000.

When can a HEX color be written with 3 digits?

A short HEX like #F80 works only when both digits of each pair are the same, as in #FF8800. That happens when each RGB value is a multiple of 17, such as 0, 17, 34, 51 and so on up to 255. The tool shows the short form whenever it is possible.

How do I convert RGBA to HEX with transparency?

Tick Include alpha and set the opacity. The alpha value is multiplied by 255 and added as a fourth pair, so 50% opacity becomes 80 and rgba(30, 144, 255, 0.5) becomes #1E90FF80. Modern browsers support 8-digit HEX in CSS.

Are HEX color codes case sensitive?

No. #1E90FF and #1e90ff are the same color in CSS, HTML and design tools. Use whichever style your project prefers. The Lowercase HEX option switches the output.

Is RGB or HEX better for CSS?

They describe exactly the same colors, so the choice is a matter of style. HEX is short and common in design handoffs, while rgb() and hsl() are easier to read and adjust, and make transparency obvious.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

HEX to RGBConvert HEX colors to RGB and other formats.RGB to CMYK ConverterConvert RGB and HEX colors to CMYK for print, and back.Color Name FinderFind the closest color name for any HEX or RGB color.Color Palette GeneratorGenerate beautiful color palettes and export them.Color Contrast CheckerCheck WCAG contrast ratios and find accessible text colors.HEX to HSLConvert HEX colors to HSL and back with interactive sliders.HEX to PantoneFind the 5 closest Pantone-style solid coated colors for any HEX or RGB, ranked by Delta E.Image Color PickerPick any pixel colour from an image and get HEX, RGB, HSL plus a palettePantone to HEXLook up approximate HEX, RGB and CMYK values for Pantone colors.Color Blindness SimulatorSee any image as people with protanopia, deuteranopia, tritanopia or achromatopsia see itColor Shades GeneratorTurn one HEX color into a 50-950 scale plus tints, shades and tones, ready to export.Tailwind Color GeneratorTurn one color into a full Tailwind 50–950 shade scale and export the config or CSS.Color MixerMix two colors in sRGB, linear, OKLab or OKLCH, or blend them with Photoshop-style modes.Random Color GeneratorGenerate random HEX colors one at a time or in batches, with hue, saturation and lightness ranges.Color WheelFind complementary, triadic, analogous and other color harmonies on an interactive wheel.Color PickerPick any color and get HEX, RGB, HSL, HSV and CMYK codes, shades and a screen eyedropper.HTML Color CodesAll 140 HTML color names with HEX and RGB codes, plus the 216 web-safe colors. Click to copy.Color Palette from ImageExtract the main colors of any photo as HEX codes, CSS variables and a palette PNG.Replace Color in ImageClick a color in a picture and swap it for a new color or transparency, keeping the shading.CMYK to RGBConvert CMYK percentages to RGB and HEX color codes with sliders and a live preview.HSL to HEXConvert HSL and HSLA colors to HEX and RGB with sliders and a live preview.HEX to RGBAConvert HEX color codes to CSS rgba() with an opacity slider and one-click copy.RGBA to HEXConvert rgba() colors to 8-digit HEX, or flatten transparency onto any background.HEX to CMYKConvert HEX color codes to CMYK percentages for print, with a live preview.Color Temperature to RGBConvert a color temperature in kelvin (1000-40000 K) to RGB and HEX with a live swatch.OKLCH Color ConverterConvert HEX, RGB and HSL to OKLCH, OKLab, Lab and LCH with sRGB and P3 gamut checks.RAL to HEXLook up RAL Classic codes as HEX, RGB and CMYK, search by name or find the nearest RAL.RGB to HSLConvert RGB values to HSL, HSV and HWB with a live swatch and copy-ready CSS.Color Code ConverterConvert a color between HEX, RGB, HSL, HSV, CMYK, LAB, LCH and OKLCH with a live swatch.Room Paint Color VisualizerUpload a room photo, select the walls and preview any paint color or HEX with real lighting.Photo to Pop ArtMake Warhol-style pop art from a photo: posterized color tiles in 1, 4 or 9 grids with custom palettes.Screen Color PickerPick any pixel color from anywhere on your screen and copy it as HEX, RGB or HSL.Solid Color Image GeneratorMake a plain single-color or transparent image in any size, like 1920x1080, as PNG or JPG.White Balance CorrectorFix color casts: click a neutral gray point or use auto gray world, then fine-tune temperature and tint.CMYK to HEXConvert CMYK percentages to a HEX color code and RGB, with a live swatch and shades.Photo Color MatchCopy the color grading of a reference photo onto your image (Reinhard color transfer).Underwater Photo Color CorrectionRestore lost reds and remove the blue or green cast from underwater photos by depth.
See all 38 Color Tools →