devkult_
tools24converters26
home/convert/rgb-to-hex

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.

Example · RGBHEX
RGB input
rgb(192, 57, 43)
rgb(29, 209, 161)
rgb(84, 160, 255)
HEX output
#c0392b
#1dd1a1
#54a0ff

Try it with your own data

RGBrgb(192, 57, 43)
Hex#C0392B
5.44: 1
PASSWCAG AA (4.5:1)
FAILWCAG AAA (7:1)

Frequently Asked Questions

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.

How to convert RGB to HEX

  1. Take your RGB value, e.g. rgb(192, 57, 43).
  2. Convert each channel to a two-digit hexadecimal number.
  3. 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.

Related converters