ImgToColor

RGB to HEX Converter

RGB to HEX converter translates Red, Green, and Blue decimal color values (0-255) into standard 6-digit hexadecimal codes (#RRGGBB) in real time. Get instant CSS ready color codes for your web design, frontend UI components, and graphic projects with complete mathematical accuracy.

#17A2B8
Active Color Sync
HEX Code#17A2B8
RGB Stringrgb(23, 162, 184)
RGB Channels (0-255)Base-10 Decimals
HEX Code (#RRGGBB)Base-16 Hexadecimal
Quick Color Presets:

Why Use Our Fast RGB to HEX Converter?

Instant Bi-Directional Sync
Convert RGB integers to HEX or reverse from HEX to RGB on the fly. Calculations execute locally in your browser with zero network lag or page refreshes.
100% Client-Side Privacy
All conversions take place entirely in your web browser memory. No color data, hex values, or design assets are ever uploaded to external servers.
Production Ready Output
Copy normalized uppercase HEX codes ready for direct insertion into CSS stylesheets, Tailwind config, HTML inline attributes, and design systems.

How to Convert RGB to HEX in 3 Simple Steps

Follow this quick guide to translate any RGB color specification into a standard hexadecimal code.

1
Enter Red, Green, and Blue Channel Values

Type or paste your Red (R), Green (G), and Blue (B) integer values ranging from 0 to 255 into their corresponding numeric fields. Each channel represents an 8-bit digital color intensity.

2
Instant Base-10 to Base-16 Translation

The conversion algorithm divides each decimal channel value by 16 to determine the quotient and remainder, assembling a standard two-digit base-16 hexadecimal pair.

3
Copy the Formatted HEX String

Click the Copy button to capture the formatted 6-character hexadecimal code (such as #17A2B8) directly to your clipboard for CSS stylesheets, Tailwind config, or UI software.

Understanding the Mathematical RGB to HEX Formula

Explore the exact base-10 to base-16 arithmetic that powers digital color representation across all modern displays.

The Base-16 Conversion Formula

An RGB color model defines each color channel using an 8-bit byte, yielding values from 0 to 255 (256 total values per channel). A hexadecimal code packs these three 8-bit bytes into a 6-character string (#RRGGBB).

First Hex Digit = Math.floor(Channel_Value / 16)
Second Hex Digit = Channel_Value % 16

For remainders between 10 and 15, base-16 uses alphanumeric letters:10=A, 11=B, 12=C, 13=D, 14=E, 15=F

Step-by-Step Practical Example

Let us convert rgb(23, 162, 184) into HEX:

  • Red (23): 23 / 16 = 1 (rem 7) => 17
  • Green (162): 162 / 16 = 10 (rem 2) => A2
  • Blue (184): 184 / 16 = 11 (rem 8) => B8
Combined HEX Code = #17A2B8

Display Hardware and the Additive Color Model

How screen emission technology and human trichromatic vision intersect with RGB and hexadecimal formats.

Additive Light

Unlike print (which uses subtractive CMYK ink absorption), screens emit light directly. When Red, Green, and Blue overlap at maximum intensity (255, 255, 255), they create pure white light.

24-Bit TrueColor

Each color channel uses 8 bits of memory (1 byte). Combining three 8-bit channels provides 24 bits of color depth, creating exactly 2^24 = 16,777,216 distinct identifiable shades.

GPU Memory Layout

Graphics shaders and framebuffers store pixels as 32-bit words (RGBA). A 6-character hex string maps directly to memory offsets with zero transformation overhead.

RGB to HEX Code Snippets for Developers

Easily integrate robust color conversion algorithms into your own JavaScript, TypeScript, Python, or CSS workflows.

JavaScript / TypeScript Implementation
function rgbToHex(r: number, g: number, b: number): string {
  const toHex = (c: number) => {
    const hex = Math.max(0, Math.min(255, Math.round(c))).toString(16);
    return hex.length === 1 ? '0' + hex : hex;
  };
  return '#' + (toHex(r) + toHex(g) + toHex(b)).toUpperCase();
}

// Example usage:
console.log(rgbToHex(23, 162, 184)); // "#17A2B8"
JavaScript (Fast Bitwise)
const rgbToHexBitwise = (r, g, b) => 
  '#' + ((1 << 24) + (r << 16) + (g << 8) + b)
    .toString(16)
    .slice(1)
    .toUpperCase();

// Example usage:
console.log(rgbToHexBitwise(255, 99, 71)); // "#FF6347"
Python 3 Formatter
def rgb_to_hex(r: int, g: int, b: int) -> str:
    r_clamped = max(0, min(255, r))
    g_clamped = max(0, min(255, g))
    b_clamped = max(0, min(255, b))
    return f"#{r_clamped:02X}{g_clamped:02X}{b_clamped:02X}"

# Example usage:
print(rgb_to_hex(23, 162, 184)) # "#17A2B8"
CSS Variables & Tailwind
/* CSS Custom Properties */
:root {
  --brand-primary-rgb: 23, 162, 184;
  --brand-primary-hex: #17A2B8;
}

.element {
  background-color: var(--brand-primary-hex);
  border-color: rgba(var(--brand-primary-rgb), 0.5);
}

Popular Color Codes: RGB to HEX Reference Table

Quick reference guide for commonly used digital design colors with their exact RGB, HEX, and HSL equivalents.

PreviewColor NameHEX CodeRGB ValueHSL ValueCategory
Pure Red#FF0000rgb(255, 0, 0)hsl(0, 100%, 50%)Primary
Pure Green#00FF00rgb(0, 255, 0)hsl(120, 100%, 50%)Primary
Pure Blue#0000FFrgb(0, 0, 255)hsl(240, 100%, 50%)Primary
Pure White#FFFFFFrgb(255, 255, 255)hsl(0, 0%, 100%)Neutral
Pure Black#000000rgb(0, 0, 0)hsl(0, 0%, 0%)Neutral
Slate Gray#708090rgb(112, 128, 144)hsl(210, 13%, 50%)UI Accent
Coral Orange#FF7F50rgb(255, 127, 80)hsl(16, 100%, 66%)Vibrant
Teal Blue#008080rgb(0, 128, 128)hsl(180, 100%, 25%)Brand
Amber Gold#FFBF00rgb(255, 191, 0)hsl(45, 100%, 50%)Warning
Royal Purple#7851A9rgb(120, 81, 169)hsl(267, 35%, 49%)Creative
Crimson#DC143Crgb(220, 20, 60)hsl(348, 83%, 47%)Alert
Midnight Navy#191970rgb(25, 25, 112)hsl(240, 64%, 27%)Dark Mode

Frequently Asked Questions About RGB to HEX

Everything you need to know about color formats, conversion algorithms, and web standards.

Explore Related Color Conversion Tools

Switch between any web color format with our comprehensive suite of free utilities.