RGB to HEX Converter
Convert RGB channels and optional alpha into a CSS HEX color.
Try a worked example
Try a worked example
Convert RGB channels and optional alpha into a CSS HEX color.
Check the units and options, then use the tool’s calculation button. The example is fictitious; replace its values for your own calculation.
Example input
- Red (0–255)
- 52
- Green (0–255)
- 152
- Blue (0–255)
- 219
- Alpha (optional, 0–1)
Expected output
RGB: 52, 152, 219 CSS color: rgb(52, 152, 219) HEX: #3498DB
Convert whole-number red, green, and blue channels into a six-digit HEX color; optionally add alpha from 0 (transparent) to 1 (opaque) for an eight-digit CSS HEX color.
Waiting for the tool. The explanation remains available without JavaScript.
Method and limits
Enter red, green, and blue as separate whole numbers from 0 to 255. For example, 52, 152, 219 gives #3498DB. Leave Alpha blank for an opaque six-digit HEX color, or enter a value from 0 (transparent) to 1 (opaque) to add the final alpha byte; 0.5 gives #3498DB80.
RGB channels must be whole numbers from 0 to 255. Alpha is rounded to the nearest 8-bit step because CSS HEX stores alpha in one byte.
Share this tool
Only the tool’s public link is shared. Your inputs and results stay here.
Show link to copy manually
Quick answer
Convert whole-number red, green, and blue channels into a six-digit HEX color; optionally add alpha from 0 (transparent) to 1 (opaque) for an eight-digit CSS HEX color.
The page and its assets load from the site; this operation uses your entered values only in this browser and does not send them to a calculation endpoint.
How to use it
Enter red, green, and blue as separate whole numbers from 0 to 255. For example, 52, 152, 219 gives #3498DB. Leave Alpha blank for an opaque six-digit HEX color, or enter a value from 0 (transparent) to 1 (opaque) to add the final alpha byte; 0.5 gives #3498DB80.
Limits
RGB channels must be whole numbers from 0 to 255. Alpha is rounded to the nearest 8-bit step because CSS HEX stores alpha in one byte.
Frequently asked questions
How do I set transparency?
Leave Alpha blank for opaque output, or enter a value from 0 (fully transparent) to 1 (fully opaque). The value is rounded to one of 256 alpha steps to fit in HEX.
What does the HEX result look like?
Without alpha it is #RRGGBB. With alpha it is #RRGGBBAA, where the final byte stores transparency.
Sources and references
These references document the cited standard or browser API; they do not validate the tool’s output.
