HEX to RGB Converter

Convert HEX and hexadecimal color codes to RGB, RGBA, HSL, and CSS values instantly in your browser.

Private by default — color conversion happens in your browser

Color converter workspace

Enter or edit a color

Supports #RGB, #RGBA, #RRGGBB, and #RRGGBBAA.

Color preview #FF8C42
preview.html

A color becomes useful when you can see it in context.

Converted color values

Ready — enter or edit a color.

Contrast preview

Readable text should remain clear against its background.

Contrast ratio 7.75:1
AA normal text Passes AA large text Passes

Contrast is calculated after transparency is composited over the background.

Convert HEX and hexadecimal colors to RGB

Use this HEX to RGB converter when a design gives you a hexadecimal color code but your CSS, JavaScript, canvas, or graphics workflow needs red, green, and blue channels. Enter a 3-, 4-, 6-, or 8-digit HEX value and the hexadecimal to RGB color conversion appears instantly. Alpha is preserved when the code includes transparency. For example, #ff8c42 converts to rgb(255, 140, 66) and hsl(23, 100%, 63%).

How to use this HEX converter

  1. Enter a HEX, RGB(A), or HSL(A) color, or choose a color visually.
  2. Edit any field; the HEX, RGB, HSL, alpha, preview, and contrast result stay synchronized.
  3. Copy one value, the CSS custom property, all formats, or a share link.

Because every format is editable, the page also works as an RGB converter when you begin with rgb() or rgba(). Use it as a hex code converter for CSS snippets or as a broader color code converter when moving values between design and development tools.

Convert HEX to HSL without losing transparency

HSL describes the same color by hue, saturation, and lightness, which can be easier to adjust than individual RGB channels. The HEX to HSL result keeps alpha from #RGBA or #RRGGBBAA input and produces HSLA when transparency is below 100%. Editing HSL updates the matching HEX and RGB values from the same color state, avoiding conversion drift between fields.

HEX, RGB, and HSL: which format should you use?

HEX is compact and common in CSS variables and design specifications. RGB exposes individual red, green, and blue channels for JavaScript, canvas, and graphics APIs. HSL is convenient when adjusting hue, saturation, or lightness. These formats describe the same color using different notation, although displayed numbers may differ slightly because of rounding.

How hexadecimal color codes work

A hexadecimal color code is the compact way RGB is written in coding: two hex digits per channel, from 00 to FF (0 to 255 in decimal), so #FF8C42 is red FF, green 8C, blue 42. Hex values use the digits 0-9 and letters A-F, hex numbers are case-insensitive, and colors in hexadecimal can also carry a fourth pair for alpha. A small hex chart helps when reading RGB in hexadecimal: #000000 is black, #FFFFFF is white, #FF0000 red, #00FF00 green, #0000FF blue, and #808080 mid grey. The converter shows the hexadecimal code, the RGB color code, and HSL side by side, so RGB to hex and hex to RGB color conversion needs no lookup table.

Check text contrast before using a color

The preview compares the selected foreground color with a background and reports their contrast ratio after alpha compositing. Use it as a quick check while converting a color, not as a complete accessibility audit: font size, weight, interaction states, borders, icons, gradients, and the rendered page still need review. For AAA, large-text, and non-text thresholds with accessible alternatives, open the full color contrast checker.

Private color conversion in your browser

Parsing, conversion, contrast calculation, and copy actions happen in this browser tab. No color is uploaded to a conversion API, and no sign-up is required. If you create a share link, the selected color is intentionally included in that link so the same state can be reopened.

Frequently asked questions

How do I convert a HEX color to RGB?

Enter the color in the HEX field. The matching RGB, HSL, alpha, CSS variable, and preview update immediately. For example, #ff8c42 converts to rgb(255, 140, 66).

Which HEX color formats are supported?

The converter supports #RGB, #RGBA, #RRGGBB, and #RRGGBBAA. The 4- and 8-digit forms include alpha transparency in the final digit or pair.

Can I convert RGB or HSL back to HEX?

Yes. Edit the RGB, RGBA, HSL, or HSLA field and the equivalent HEX value updates automatically. Every displayed format is derived from the same underlying RGBA color.

How is HEX converted to HSL?

The converter first resolves the HEX value into RGB channels, then calculates hue, saturation, and lightness from the channel range. Only the displayed values are rounded, which keeps all fields synchronized.

Are my color codes uploaded or stored?

No color is uploaded to a conversion service. Conversion and copying run locally in your browser. A share link includes the selected color in the link only when you explicitly create one.

What does RGB stand for in a HEX code?

RGB stands for red, green, and blue, the three light channels a screen mixes to display a color. A six-digit HEX code writes those same three channels in hexadecimal, two digits each, in red-green-blue order; an eight-digit HEX code adds a fourth pair for alpha (opacity).

Put the color into a working webpage

Phoenix Code gives you HTML and CSS editing, project-wide search, Git, and Live Preview in a full browser or desktop code editor.