Free RGB to HEX Converter

Enter any RGB or RGBA value and instantly get the HEX code plus HSL, CMYK, and 7 other color formats.

Could not parse color

Color Preview

#000000

rgb(0, 0, 0)

hsl(0, 0%, 0%)

black

Color Picker

100%

All Formats

HEX

HEX (no #)

RGB

RGBA

HSL

HSLA

HSV/HSB

CMYK

CSS Name

Integer

Pro Tips

  • Type any format directly: #FF5733, rgb(255,87,51), coral
  • Use the color picker for visual selection, or combine both methods
  • Switch to Bulk CSS Converter to convert entire stylesheets at once
  • The CSS Name finder uses Euclidean distance to find the closest match from all 148 named colors
  • All 10 output formats update live as you type or pick

Last updated: March 2026

How to Convert RGB to HEX

Converting RGB color values to HEX codes is essential for web developers and designers. RGB defines colors using three decimal numbers from 0 to 255, while HEX uses a compact six-character hexadecimal string that is the standard format in CSS, HTML attributes, and design tools like Figma and Sketch.

To convert, simply paste your RGB value into the input field above. The tool accepts standard CSS notation like rgb(255, 87, 51) and automatically outputs the HEX equivalent along with nine other color formats. No need to do any math — the conversion is instant and accurate.

The RGB to HEX Conversion Formula

The conversion from RGB to HEX is a base-10 to base-16 transformation applied to each color channel independently:

  1. Take the red value (0-255) and convert to hexadecimal. For 255: 255 / 16 = 15 remainder 15, which is FF.
  2. Repeat for green. For 87: 87 / 16 = 5 remainder 7, which is 57.
  3. Repeat for blue. For 51: 51 / 16 = 3 remainder 3, which is 33.
  4. Combine with a hash prefix: #FF5733

Each channel value maps to exactly two hex digits, with values below 16 getting a leading zero (e.g., 10 becomes 0A). This conversion is completely lossless — the identical color is represented in both notations.

When to Use RGB vs HEX

Use HEX when writing CSS stylesheets, storing colors in design tokens, sharing color values with teammates, or copying from design tools. HEX is more compact and universally recognized in web development contexts.

Use RGB when you need to manipulate individual color channels in JavaScript, work with canvas drawing operations, or need transparency via RGBA. RGB is also more human-readable when you need to quickly understand a color's composition — rgb(255, 0, 0) is obviously pure red, while #FF0000 requires hexadecimal knowledge.

Use RGBA when you need semi-transparent colors. While 8-digit HEX supports alpha, RGBA is more widely supported in older browsers and more readable. For example, rgba(37, 99, 235, 0.5) is clearly a half-transparent blue.

Common RGB to HEX Examples

  • rgb(255, 255, 255)#FFFFFF — White
  • rgb(0, 0, 0)#000000 — Black
  • rgb(37, 99, 235)#2563EB — Blue
  • rgb(16, 185, 129)#10B981 — Emerald
  • rgb(239, 68, 68)#EF4444 — Red
  • rgb(245, 158, 11)#F59E0B — Amber

Frequently Asked Questions

How do I convert RGB to HEX?

To convert RGB to HEX, take each channel value (0-255) and convert it to a two-digit hexadecimal number. For rgb(255, 87, 51): 255 = FF, 87 = 57, 51 = 33, giving you #FF5733. This tool does the conversion automatically — just type or paste any RGB value and the HEX code appears instantly.

What RGB format does the converter accept?

The converter accepts standard CSS RGB notation like rgb(255, 87, 51) as well as RGBA with alpha like rgba(255, 87, 51, 0.5). It also handles the modern CSS syntax with spaces instead of commas. You can paste values directly from your browser DevTools, design software, or any other source.

Can I convert RGBA to HEX with transparency?

Yes. When you enter an RGBA value with an alpha channel, the tool generates an 8-digit HEX code where the last two digits represent the alpha value. For example, rgba(255, 87, 51, 0.5) converts to #FF573380. This format is supported in all modern browsers.

Why would I need to convert RGB to HEX?

HEX codes are the standard color format in CSS, HTML, and most design tools. They are more compact than RGB values and easier to copy-paste into stylesheets. Many design handoff tools like Figma and Zeplin display colors as HEX by default, so converting RGB to HEX ensures consistency across your workflow.

What happens if my RGB values are out of range?

RGB channel values must be between 0 and 255. If you enter a value above 255, the converter clamps it to 255. Values below 0 are clamped to 0. This ensures the output is always a valid HEX color code.

Related Tools