RGB to HEX Converter

Convert RGB channel values to a HEX color code instantly. Enter red, green and blue values (0–255) and get the exact HEX output — with HSL, HSV and CMYK values shown at the same time.

Format: red, green, blue (each 0–255). Example: 21, 94, 239

Converted Values

HEX #155EEF
RGB rgb(21, 94, 239)
HSL hsl(215, 84%, 51%)
HSV hsv(215, 84%, 94%)
CMYK cmyk(91%, 61%, 0%, 6%)

What Is RGB to HEX Conversion?

RGB to HEX conversion translates three integer channel values (red, green and blue, each from 0 to 255) into a compact six-digit hexadecimal code. Both describe the same visible color in the sRGB color space, but HEX is the preferred notation in CSS and HTML while RGB is the natural form in graphics programming.

OmniColor's RGB to HEX converter is precise, instant, and shows the resulting HEX, HSL, HSV and CMYK at the same time so you can switch formats without leaving the page.

How RGB to HEX Works (The Math)

Each RGB channel is converted from decimal (0–255) to hexadecimal (00–FF). The three two-digit values are then concatenated with a leading #:

rgb(21, 94, 239)

  Red   21  → 15 (hex)
  Green 94  → 5E (hex)
  Blue  239 → EF (hex)

Result: #155EEF

Because each channel fits in one byte (0–255), the conversion is lossless — the HEX code always describes exactly the same color as the original RGB values.

Example Conversions

  • rgb(255, 255, 255) → #FFFFFF — white
  • rgb(0, 0, 0) → #000000 — black
  • rgb(255, 0, 0) → #FF0000 — pure red
  • rgb(21, 94, 239) → #155EEF — OmniColor blue
  • rgb(135, 206, 235) → #87CEEB — SkyBlue

Uses of RGB to HEX Conversion

  • CSS colors: Paste the HEX code directly into color or background properties.
  • Design handoff: Designers convert RGB from design tools to HEX for developers.
  • Brand guidelines: Most brand guides specify colors as HEX codes, not RGB triplets.
  • HTML attributes: <input type="color"> and many HTML attributes expect HEX.
  • Data export: Many APIs and JSON files use HEX for portability.

Accuracy

Because RGB and HEX are both representations of the sRGB color space with 8 bits per channel, the conversion is mathematically exact and reversible. No color fidelity is lost — an RGB value and its HEX equivalent are literally the same color, just written in different notations.

Frequently Asked Questions