RGB (Red, Green, Blue) is the standard color model for digital displays, where each channel ranges from 0 to 255. HEX color codes are shorthand notation in CSS and HTML representing RGB values as six-character hexadecimal (e.g., #FF5733). Converts RGB to HEX with live preview and ready-to-copy CSS.
rgb(255, 87, 51)
hsl(11, 100%, 60%)
color: #FF5733;color: rgb(255, 87, 51);color: hsl(11, 100%, 60%);Enter Red, Green, and Blue values (each 0-255) using the number inputs or sliders. The corresponding HEX color code is generated instantly with a live color preview. Click the color swatch to open a visual color picker. The tool provides ready-to-copy CSS snippets in HEX, RGB, and HSL formats.
RGB-to-HEX conversion is commonly needed when working with design tools that output RGB values (like the browser's color picker or DevTools), converting programmatically-generated colors to CSS HEX format, creating consistent color references in style guides and design systems, and generating HEX codes for use in email templates, SVG attributes, and non-CSS contexts that require hexadecimal color notation.
Each RGB channel (0-255) is converted to a two-digit hexadecimal string using toString(16) with zero-padding. The three hex pairs are concatenated with a # prefix: rgb(255, 128, 0) becomes FF + 80 + 00 = #FF8000. The tool also computes the equivalent HSL values. Input ranges are validated and clamped to 0-255. For alpha/transparency support, see the dedicated RGBA to HEX converter.
Enter the Red, Green, and Blue values (each 0-255) and the tool instantly calculates the HEX code. Each color channel is converted to a two-digit hexadecimal number: R=255 → FF, G=87 → 57, B=51 → 33, so rgb(255, 87, 51) = #FF5733.
Each RGB value (0-255) is converted to hexadecimal (base 16). For example, 255 in hex is FF, 0 is 00, and 128 is 80. The three hex pairs are concatenated with a # prefix: rgb(255, 128, 0) becomes #FF8000.
This tool handles standard 3-channel RGB (no alpha). For RGBA with transparency, use the dedicated RGBA to HEX converter which generates 8-digit HEX codes (#RRGGBBAA).
HEX codes are shorter (7 characters vs 16+ for rgb()), widely recognized, easy to copy-paste, and are the traditional format in CSS. However, rgb() is more readable and easier to manipulate programmatically.
Transform, format, generate, and encode data instantly. Private, fast, and always free.
Browse All Tools