Skip to content

HEX to RGB Converter

Convert CSS hexadecimal colors into exact red, green, blue, and optional alpha channel values.

Privacy: your files never leave your device. All processing happens locally in your browser.

How to use

  1. 1.Paste a CSS hexadecimal color beginning with # in three-, four-, six-, or eight-digit form.
  2. 2.Read the normalized hexadecimal value, CSS rgb or rgba string, and individual channel values.
  3. 3.Check the live preview and, for translucent colors, retain the alpha byte when exact round-trip precision matters.

About HEX to RGB Converter

Hex to RGB Converter translates CSS hexadecimal color notation into red, green, blue, and optional alpha values. Enter a hash followed by three, four, six, or eight hexadecimal digits. The result shows the expanded lowercase hexadecimal form, the individual channel bytes, a CSS rgb() or rgba() representation, and a visual color preview. Four- and eight-digit inputs include transparency; three- and six-digit inputs do not specify alpha and are treated as fully opaque for the preview. Conversion is immediate and runs entirely in the current browser. The color string is not uploaded to Lizely.

The accepted syntax follows CSS hexadecimal color notation rather than every shorthand that a design application might tolerate. A leading # is required. Valid forms are #RGB, #RGBA, #RRGGBB, and #RRGGBBAA, using digits 0 through 9 and letters A through F without spaces inside the value. Uppercase and lowercase letters mean the same thing. The converter trims ordinary whitespace around the complete value, but it rejects missing hashes, incorrect lengths, doubled hashes, embedded whitespace, and characters outside the hexadecimal alphabet. This strict boundary makes an invalid CSS token visible instead of silently guessing what the author intended.

Short notation expands by duplicating each nibble. For example, #123 means #112233, so its channel bytes are 17, 34, and 51. The same rule applies to alpha: #0f08 expands to #00ff0088. Red comes first, green second, blue third, and alpha last when alpha is present. This is important because some eight-digit color conventions outside CSS place opacity first, but CSS #RRGGBBAA places it at the end. The tool never interprets #AARRGGBB as a CSS color and does not reorder an input based on its apparent visual result.

Each two-digit component is an integer byte from 0 through 255. The endpoints 00 and FF become 0 and 255. An alpha byte is divided by 255 to obtain opacity from 0 through 1. For readable CSS output, a non-endpoint alpha value is displayed to three decimal places with trailing zeros removed; the exact alpha byte remains visible alongside it, and the percentage is shown to two decimal places. Thus 80 hexadecimal is stored as byte 128 and displayed as approximately 0.502 opacity, while 00 is exactly 0 and FF is exactly 1. This display rounding does not change the original normalized eight-digit hexadecimal value.

Use the channel values when an API, canvas operation, image editor, test fixture, or design token needs separate integer inputs. Use the CSS output for styles that accept rgb() or rgba(). Keep the normalized HEX value when exact round trips matter, especially when alpha is not exactly representable with a short decimal. The preview uses the generated CSS color in the browser and helps catch an obvious channel-order mistake, but it is not a color-management reference. Screens, browser profiles, display brightness, ambient light, and wide-gamut workflows can make the same numeric sRGB color appear different.

This converter does not parse named colors such as rebeccapurple, hsl(), lab(), lch(), color(), system colors, CSS variables, gradients, or comma-separated palettes. It does not convert between color spaces, measure contrast, choose an accessible foreground, sample pixels from an image, or claim that two colors look identical. Hexadecimal CSS colors represent sRGB channel values; they are not Pantone, CMYK, printer ink recipes, or physical measurements. Use Color Contrast Checker for a contrast ratio and RGB to CMYK for a basic process-color estimate, while remembering that print production needs a managed profile and proofing workflow.

For a dependable workflow, copy the complete CSS token including its hash, check that the expected number of digits is present, and compare the displayed channel values with the system that will consume them. If transparency matters, verify that the source uses CSS's alpha-last order. Retain the normalized eight-digit HEX value when sharing an exact translucent color, because a rounded decimal alpha can lose a small amount of precision. Invalid or empty input replaces the prior conversion with a clear error, so a stale successful result is never presented as though it belongs to the current value.

Methodology & sources

The parser requires a hash and exactly 3, 4, 6, or 8 ASCII hexadecimal digits. Three- and four-digit forms duplicate each nibble, then red, green, blue, and optional final alpha bytes are parsed in base 16. Alpha equals its byte divided by 255; display text uses up to three decimals while preserving the exact byte and normalized HEX.

Frequently asked questions

Which hexadecimal color formats are accepted?
The converter accepts CSS #RGB, #RGBA, #RRGGBB, and #RRGGBBAA notation. The leading hash is required.
How does a three- or four-digit color expand?
Each digit is duplicated: #123 becomes #112233, and #0f08 becomes #00ff0088.
Where is alpha in an eight-digit CSS hex color?
Alpha is the final byte in #RRGGBBAA. The converter does not treat the first byte as alpha.
Why is alpha shown as a rounded decimal?
CSS alpha is the byte divided by 255. The readable rgba value uses up to three decimal places, while the exact 0-255 alpha byte and normalized HEX remain visible.
Does the converter upload my color data?
No. Parsing, formatting, validation, and preview rendering happen locally in the current browser.

Color Tools guides

View all