Convert RGB to HEX
Hex codes are the most compact way to write colors in CSS and HTML. This converter turns rgb() values into their six-digit hexadecimal equivalent, ready to paste into a stylesheet or design token.
rgb(192, 57, 43) rgb(29, 209, 161) rgb(84, 160, 255)
#c0392b #1dd1a1 #54a0ff
Try it with your own data
How to convert RGB to HEX
- Take your RGB value, e.g. rgb(192, 57, 43).
- Convert each channel to a two-digit hexadecimal number.
- Concatenate them with a leading # to get #c0392b.
Frequently asked questions
Why is my hex value six characters?
Each of the red, green, and blue channels becomes two hex digits (00–ff), so a full color is six digits plus the leading #.
Can RGB always be represented as hex?
Standard 8-bit RGB (0–255 per channel) maps exactly to six-digit hex. Alpha needs an eighth pair (#rrggbbaa) or rgba() instead.
What is WCAG?
The Web Content Accessibility Guidelines (WCAG) define how to make web content more accessible to people with disabilities. Contrast ratios are a key part of these guidelines to ensure text is readable against its background.
What contrast ratio should I aim for?
Level AA requires a contrast ratio of at least 4.5:1 for normal text and 3:1 for large text. Level AAA requires at least 7:1 for normal text and 4.5:1 for large text.