RGB to Hex Color Converter

Convert RGB color values to hexadecimal codes instantly. Preview colors, get detailed color information, and work with multiple color formats.

RGB to Hex Conversion: RGB (Red, Green, Blue) values represent colors using three decimal numbers (0-255) for each color component.

Hexadecimal color codes are a compact representation of these values using base-16 notation (0-9, A-F).

RGB Color Components
Red
2C
Green
7D
Blue
A0
Enter values 0-255 for each RGB component or use the sliders to adjust. Values outside this range will be clamped.
Common RGB Colors
RGB(44, 125, 160)
#2C7DA0
RGB(232, 62, 140)
#E83E8C
RGB(40, 167, 69)
#28A745
RGB(255, 193, 7)
#FFC107
RGB(220, 53, 69)
#DC3545
RGB(111, 66, 193)
#6F42C1
Choose how you want the hex code displayed
Hold Ctrl/Cmd to select multiple formats
Use shorthand hex when possible:
RGB Color
RGB(44, 125, 160)
Hex Color
#2C7DA0
Converting...
Color Conversion Results
1 RGB to Hexadecimal Conversion

Each RGB component (0-255) is converted to a 2-digit hexadecimal value:

Red: 442C
Green: 1257D
Blue: 160A0
Combined: 2C + 7D + A0 = #2C7DA0
Red Component
44
Decimal
Hex: 2C
Green Component
125
Decimal
Hex: 7D
Blue Component
160
Decimal
Hex: A0
Color in Different Formats
Format Syntax Value Action
Hexadecimal (Full) #RRGGBB #2C7DA0
Hexadecimal (Short) #RGB #2C7DA0
RGB RGB(r, g, b) RGB(44, 125, 160)
RGBA RGBA(r, g, b, a) RGBA(44, 125, 160, 1)
HSL HSL(h, s%, l%) HSL(198, 57%, 40%)
HSLA HSLA(h, s%, l%, a) HSLA(198, 57%, 40%, 1)
CSS rgb() rgb(r, g, b) rgb(44, 125, 160)
CMYK CMYK(c, m, y, k) CMYK(73%, 22%, 0%, 37%)
Color Harmony
Complementary
#A07D2C
Analogous
#2CA07D
Original
#2C7DA0
Analogous
#2C5AA0
Triadic
#A02C7D
Triadic
#7DA02C

These are harmonizing colors that work well with your selected color in design projects.

Understanding RGB and Hexadecimal Colors

RGB (Red, Green, Blue) and hexadecimal color codes are two fundamental ways to represent colors in digital design, web development, and computer graphics.

RGB Color Model:

The RGB color model is an additive color model in which red, green, and blue light are added together in various ways to reproduce a broad array of colors. Each component ranges from 0 to 255.

RGB(Red, Green, Blue)

Where Red, Green, and Blue are integer values between 0 and 255 inclusive.

Hexadecimal Color Codes:

Hexadecimal colors are a compact representation of RGB values using base-16 notation. Each pair of hexadecimal digits represents one RGB component:

#RRGGBB

Where RR (red), GG (green), and BB (blue) are hexadecimal values ranging from 00 to FF (0 to 255 in decimal).

Conversion Formula

Decimal to Hexadecimal Conversion:

To convert a decimal value (0-255) to hexadecimal:

  1. Divide the decimal number by 16
  2. Write down the quotient and remainder
  3. Convert both to hexadecimal digits (0-9, A-F)
  4. Combine the two digits

Example: Convert 125 to hexadecimal:

125 ÷ 16 = 7 remainder 13
7 = 7 in hex, 13 = D in hex
Result: 7D

Alternative method: Decimal value → toString(16) → pad with leading zero if needed

Shorthand Hexadecimal Notation

1

3-digit Hex Codes: When each pair of hexadecimal digits consists of the same digit (e.g., #FFCC99), it can be shortened to 3 digits (#FC9). This is a CSS shorthand notation that reduces file size and improves readability.

2

When to Use Shorthand: Shorthand notation is only possible when each color component's hexadecimal representation consists of two identical digits (00, 11, 22, ..., EE, FF). For example, #FF8844 cannot be shortened because 88 and 44 are pairs of identical digits, but FF is also a pair.

Common Color Code Formats

Format Example Description Usage
6-digit Hex #2C7DA0 Standard hexadecimal color code Web design, CSS, HTML
3-digit Hex #2A8 Shorthand for #22AA88 CSS shorthand notation
RGB RGB(44, 125, 160) Red, Green, Blue values (0-255) Graphic design, programming
RGBA RGBA(44, 125, 160, 0.5) RGB with alpha transparency (0-1) CSS with transparency
HSL HSL(198°, 57%, 40%) Hue, Saturation, Lightness CSS, intuitive color adjustment
CMYK CMYK(73%, 22%, 0%, 37%) Cyan, Magenta, Yellow, Key (Black) Print design, professional printing

Applications of RGB and Hex Colors

  • Web Design: CSS styling, background colors, text colors
  • Graphic Design: Digital artwork, logos, branding materials
  • User Interfaces: Button colors, themes, visual feedback
  • Game Development: Textures, lighting, visual effects
  • Data Visualization: Charts, graphs, heatmaps
  • Digital Photography: Color correction, image editing

Converter Features:

  • Converts RGB values (0-255) to hex codes
  • Provides real-time color preview and multiple output formats
  • Includes RGB component sliders and input fields
  • Generates color harmonies for design inspiration
  • Supports shorthand hex notation when applicable
  • Offers copy functionality for all color formats
  • Includes popular color examples for quick testing

Frequently Asked Questions

RGB uses three decimal numbers (0-255) to represent red, green, and blue components. Hexadecimal codes use base-16 notation (0-9, A-F) to represent the same values in a more compact form. They are mathematically equivalent, just different representations of the same color data.

3-digit hex codes are shorthand that can be used when each pair of hexadecimal digits in a 6-digit code are identical (e.g., #FFCC99 becomes #FC9). They save space in CSS files and improve readability. However, not all colors can be represented with 3-digit codes—only those where each color component's hexadecimal value consists of two identical digits.

This converter will clamp values to the valid range (0-255). Values less than 0 will be treated as 0, and values greater than 255 will be treated as 255. This ensures that the resulting hex code is always valid. Some applications might handle out-of-range values differently, but for web colors, values must be within the 0-255 range.

Hexadecimal notation uses digits 0-9 and letters A-F (or a-f) to represent values 0-15. Since the letters A-F and a-f represent the same values (10-15), hex codes are case-insensitive. #2c7da0 and #2C7DA0 represent the same color. However, some developers prefer uppercase for consistency, while others prefer lowercase for readability.

RGB is an additive color model used for screens (adding light to create colors). CMYK is a subtractive color model used for printing (subtracting light by adding ink). RGB has a larger gamut (range of colors) than CMYK, which is why colors can look different on screen versus in print. This converter includes CMYK output for print design purposes.