RGB to HEX Converter
Type or paste any rgb() value, legacy commas, modern spaces, percentages or alpha, and get the hex code instantly, alongside HSL, HWB and OKLCH. Local, with one-click copy.
Advanced spaces & developer export
Contrast checker
WCAG contrast applies to the final rendered colors. Transparent foregrounds and backgrounds are composited over the backdrop below, exactly like a browser renders them, before the ratio is calculated.
AA needs 4.5:1 for normal text, 3:1 for large (24px, or 18.5px bold). AAA needs 7:1 and 4.5:1.
Tints, shades & harmonies
Generated in OKLCH (perceptually even lightness steps, constant hue) and gamut-mapped to sRGB. Click any swatch to copy its hex.
From screen values to stylesheet, without transcription errors
RGB values arrive from everywhere: a screenshot eyedropper, a design handoff, a JavaScript canvas readout, a legacy database. The failure mode is manual transcription, one channel copied wrong and the brand blue is suddenly someone else's. Paste the whole rgb() string here instead: the parser is strict, so a malformed value errors loudly rather than converting garbage, and the eyedropper button (in browsers that support it) lets you skip the transcription entirely by picking the color straight off your screen.
RGB to HEX FAQ
How does RGB to HEX conversion work?
Each RGB channel (0-255) converts to a two-digit base-16 number, and the three pairs are joined behind a #. rgb(37, 99, 235) becomes #2563EB: 37 is 25 in hex, 99 is 63, 235 is EB. Alpha, if present, appends a fourth pair: 50% opacity is 80. Paste any rgb() or rgba() value above, legacy commas or modern spaces, and the hex appears live with a copy button.
Does the converter accept the modern CSS rgb() syntax?
Yes, all of it: legacy rgb(37, 99, 235) and rgba(37, 99, 235, 0.5), modern rgb(37 99 235) and rgb(37 99 235 / 50%), and percentage channels like rgb(15% 39% 92%). Anything the CSS Color 4 grammar allows parses here; anything it forbids gets a specific error instead of a silent guess.
What happens to alpha when converting RGB to HEX?
It becomes the fourth pair of an 8-digit hex code: rgb(255 0 0 / 0.5) converts to #FF000080. Both values mean the same color. Note that 8-digit hex is supported by all current browsers but some older tooling chokes on it; when that happens, keep the rgba() form, which this page shows alongside.
Why would I convert to HEX at all?
Compactness and universality: hex pastes cleanly into every design tool, email template and legacy system ever made. Keep rgb() when you need obvious alpha, and consider oklch() for design-system work where perceptual uniformity matters. This converter emits all of them at once so the choice costs nothing.
More free tools: Color Converter · HEX to RGB · HSL to HEX · Contrast Checker · OKLCH Picker