RGB to Hex Color Converter
Convert RGB or HSL values to a hex color code with a live preview and WCAG contrast ratio.
- RGB
- 28, 31, 33
- HSL
- 204°, 8%, 12%
- CSS
- rgb(28, 31, 33)
- Contrast vs #1c1f21
- 1.00:1
RGB expresses a color as three channels of red, green, and blue, each from 0 to 255. It maps directly to how screens emit light, which is why design and development tools use it natively.
The hex output is the compact six-digit form used in CSS, design systems, and tokens. Converting rgb(168, 121, 44) gives #a8792c, which is easier to copy into a stylesheet or a config file.
RGB and hex are interchangeable: both are 8-bit-per-channel representations of the same color. This tool also shows the HSL equivalent for design adjustments.
Common uses
- Converting a color picked in a design tool (shown as RGB) into the hex token needed by a Tailwind config or CSS variable.
- Generating a compact hex string to paste into a JSON theme file or an inline style.
Frequently asked questions
- Why do some hex codes have 3 or 8 digits?
- Three digits are shorthand for pairs (#0f3 = #00ff33). Eight digits add an alpha channel at the end. This tool outputs the standard six-digit opaque form.
- Do I need to clamp RGB values to 0-255?
- Yes. Values outside that range are not meaningful on screen. The converter clamps automatically so you always get a valid hex code.
- Is hex more precise than RGB?
- No. Both are 8-bit-per-channel representations of the same color. They are interchangeable without any loss of precision.