RGB to HEX Converter
Convert RGB and RGBA values into a HEX color code. Enter channels as a full rgb() string, an rgba() string with alpha, or individual numbers, and get the matching 6-digit HEX immediately. When an alpha value is present, the converter also produces an 8-digit HEX so you keep transparency. Input is validated and out-of-range channels are flagged clearly rather than being quietly clamped without notice. Alongside the HEX result you see the HSL equivalent and the nearest CSS color name for context, and every value copies with a single click. The conversion uses the same tested color engine as the rest of the site, so a color looks identical no matter which tool you use.
| Format | Value | Copy |
|---|
How to use the RGB to HEX Converter
- Enter RGB values. Type an rgb() or rgba() string, or enter red, green, blue, and optional alpha.
- Read the HEX output. See the 6-digit HEX, plus an 8-digit HEX when alpha is present.
- Copy the code. Click copy to grab the HEX value for your stylesheet or design tool.
Examples
- Standard RGB: rgb(52, 152, 219) converts to #3498db.
- RGB with alpha: rgba(52, 152, 219, 0.5) converts to #3498db80.
How it works
RGB to HEX rewrites each 0–255 channel as a two-digit base-16 number. Alpha, if present, is scaled from 0–1 to 0–255 and appended as a fourth pair. The mapping is direct, so the only reason a value might shift is if a channel is out of range, which the converter reports.
Common use cases
- Turning canvas or JavaScript RGB values into a HEX for CSS
- Storing a translucent color as a single 8-digit HEX
- Normalizing mixed color formats to HEX in a codebase
Privacy
All color calculations run in your browser. Nothing you enter is sent to a server. Saved palettes and recent colors are kept only in your browser’s local storage and can be cleared at any time.
Frequently asked questions
Can I paste a full rgb() string?
Yes. Paste rgb(52, 152, 219) or rgba(52, 152, 219, 0.5) directly, or enter channels individually.
How is alpha represented in HEX?
Alpha becomes the last two digits of an 8-digit HEX, scaled from 0–1 to 00–ff.
What if a channel is out of range?
Values outside 0–255 are flagged so you can correct them rather than getting a silently altered color.
Does modern space syntax work?
Yes. Both comma syntax and modern rgb(52 152 219 / 0.5) syntax are accepted.