RGB to HEX Converter
Convert standard red, green, blue color profiles into short hexadecimal codes.
rgb(59, 130, 246)
HEX Output
#3B82F6
How to Use
Enter the Red channel value (0–255)
Input the red component of your color from 0 (no red) to 255 (full red).
Enter the Green channel value (0–255)
Input the green component from 0 to 255.
Enter the Blue channel value (0–255)
Input the blue component from 0 to 255 to complete the RGB triplet.
Copy the hex output
Get the #RRGGBB hex string ready to paste into CSS, HTML, SVG, or design tools.
How RGB works
The RGB structure consists of three parameters, representing the Red, Green, and Blue channels. The parameters span from 0 to 255. Converting this 3-number array base-10 format into a clean base-16 string ensures concise CSS styling.
Real-World Examples & Use Cases
CSS and HTML Stylesheet Authoring
CSS color properties (color, background-color, border-color, box-shadow) accept hex codes as the most concise notation. When an image editing tool or color picker provides an RGB readout (e.g. from color sampling a screenshot), developers need to convert to hex before writing it into their stylesheet. A designer extracting a brand color from a photo may get rgb(34, 197, 94) from their eyedropper — converting to #22C55E produces the clean hex value for the design system.
Design File Color Specification
Design-to-developer handoffs require consistent color notation. Figma, Adobe XD, and Sketch all display and export colors in hex notation within their inspect panels. When a developer receives colors from a design tool that exposed RGB values (older photo editing workflows, color calibration data, or color science pipelines), converting to hex ensures the values integrate cleanly into CSS design tokens, Tailwind config files, and component library theme objects that standardize on hex notation.
Programmatic Color Generation
Applications that generate colors programmatically — gradient generators, color scheme algorithms, procedural art, data visualization — often compute RGB channel values mathematically before needing the hex code representation for display. A chart library computing a 10-step color ramp from red to blue interpolates R, G, B values at each step and must convert each to hex for CSS output. Color blending, shade generation, and tint calculation all produce numerical RGB values that need hex conversion for browser rendering.
SVG and Canvas Drawing Code
SVG fill and stroke attributes use hex color strings: fill='#3B82F6'. When SVG colors are computed from data values (e.g. choropleth maps where darker shades represent higher values), the RGB channel values are calculated mathematically and need to be formatted as hex strings for the SVG attribute. Similarly, Canvas 2D contexts accept hex strings for fillStyle and strokeStyle, making RGB-to-hex conversion a routine step in dynamic visualization and generative graphics code.
How It Works
RGB to HEX conversion formula: Each channel (0–255) is converted to a 2-digit base-16 number: Hex digit = channel.toString(16).padStart(2, '0') R: decimal → 2-digit hex (uppercase) G: decimal → 2-digit hex (uppercase) B: decimal → 2-digit hex (uppercase) Result: '#' + RR + GG + BB Examples: (59, 130, 246): R: 59 → 3B G: 130 → 82 B: 246 → F6 Result: #3B82F6 (255, 255, 255) → #FFFFFF (white) (0, 0, 0) → #000000 (black) (128, 128, 128) → #808080 (medium gray) Decimal to Hex conversion: 0-9 maps directly; 10=A, 11=B, 12=C, 13=D, 14=E, 15=F For values 16+: divide by 16, first digit = quotient, second = remainder 130 ÷ 16 = 8 remainder 2 → 82
Frequently Asked Questions
Why does the hex code always have exactly 6 characters?▼
What RGB value represents white, black, and gray?▼
How many unique colors can RGB represent?▼
Can I use RGB values in CSS directly instead of converting to hex?▼
Why do some hex codes appear to have repeated characters like #AABBCC?▼
Related Tools
Explore other tools in this category.
HEX to RGB Converter
Convert hexadecimal web color codes to RGB system values instantly.
Color Picker
Select dynamic colors and extract both HEX and RGB strings simultaneously.
CSS Gradient Generator
Create beautiful linear and radial CSS gradients with a live visual editor and instant code output.
Glassmorphism Generator
Generate the popular frosted glass CSS effect with blur, transparency, and border controls.
Color Palette Generator
Generate harmonious color palettes from any base color using color theory rules.